https://github.com/ajitjha393/parikshit
A simple and scalable JavaScript testing framework written in Typescript!
https://github.com/ajitjha393/parikshit
haste-map jest js testing watchman
Last synced: about 1 month ago
JSON representation
A simple and scalable JavaScript testing framework written in Typescript!
- Host: GitHub
- URL: https://github.com/ajitjha393/parikshit
- Owner: ajitjha393
- Created: 2022-08-17T09:11:56.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-27T12:31:38.000Z (about 3 years ago)
- Last Synced: 2024-04-23T22:39:34.461Z (over 1 year ago)
- Topics: haste-map, jest, js, testing, watchman
- Language: TypeScript
- Homepage:
- Size: 135 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Parikshit
Parikshit is a simple and scalable JavaScript testing framework written in Typescript.
It is inspired by the [Jest](https://jestjs.io/) framework and is built on top the Facebook's `Haste module system`
## Features Supported
- [x] File system search
- [x] Run multiple tests parallely
- [x] Assertion framework (`expect`, `toBe`, `toThrow`, etc.)
- [x] Mocking functionality
- [x] Run specific test file passed from the CLI
- [x] Basic Test Runner suite (`describe`, `it`)
- [x] Isolated Test environment (using `vm`)
- [x] A module system support for the test files## Haste Module System
```ts
class HasteMap extends EventEmitter {}type HasteMap = {
clocks: WatchmanClocks,
files: {[filepath: string]: FileMetaData},
map: {[id: string]: ModuleMapItem},
mocks: {[id: string]: string},
}```
Parikshit uses the HasteMap implementation, which is inspired by [Node-Haste](https://github.com/facebook/node-haste) and was built with for high-performance in large code repositories with hundreds of thousands of files. This implementation is scalable and provides predictable performance.
It makes use of worker processes for parallelizing the file access operations and metadata extraction.
## Examples:
1. **Run a single test file `describe.test.js`**
```ts
const banana = require('./banana.js')
const apple = require('./apple.js')it('tastes good', () => {
expect(banana).toBe('good')
})it('tastes good too', () => {
expect(apple).toBe('good')
})describe('Describe test', () => {
it('this should work', () => {
expect(1).toBe(1)
})
})describe('Second Describe test', () => {
it(`Test for checking async code`, async () => {
await new Promise(resolve => setTimeout(resolve, 200))
expect(1).toBe(2)
})
})```
- `Output`

2. **Run entire test suite in the current project**
