Skip to content

A simple and scalable JavaScript testing framework written in Typescript!

Notifications You must be signed in to change notification settings

ajitjha393/Parikshit

Repository files navigation

Parikshit

Parikshit is a simple and scalable JavaScript testing framework written in Typescript.

It is inspired by the Jest framework and is built on top the Facebook's Haste module system

Features Supported

  • File system search
  • Run multiple tests parallely
  • Assertion framework (expect, toBe, toThrow, etc.)
  • Mocking functionality
  • Run specific test file passed from the CLI
  • Basic Test Runner suite (describe, it)
  • Isolated Test environment (using vm)
  • A module system support for the test files

Haste Module System

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 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
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

image

  1. Run entire test suite in the current project

image

About

A simple and scalable JavaScript testing framework written in Typescript!

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published