0.4.18 • Published 10 years ago
jest-cli-browser-support v0.4.18
Jest 
THIS IS A FORK OF JEST
- Support for browser aliases.
- Code coverage
- and it ignores handlebars files! so if you are using hbsfy you won't be screwed
Painless JavaScript Unit Testing
Familiar Approach: Built on top of the Jasmine test framework, using familiar expect(value).toBe(other) assertions
Mock by Default: Automatically mocks CommonJS modules returned by require(), making most existing code testable
Short Feedback Loop: DOM APIs are mocked and tests run in parallel via a small node.js command line utility
Getting Started
Check out the Getting Started tutorial. It's pretty simple!
API
<generated_api_start />
The jest object
jest.autoMockOff()jest.autoMockOn()jest.clearAllTimers()jest.dontMock(moduleName)jest.genMockFromModule(moduleName)jest.genMockFunction()jest.genMockFn()jest.mock(moduleName)jest.runAllTicks()jest.runAllTimers()jest.runOnlyPendingTimers()jest.setMock(moduleName, moduleExports)
Mock functions
mockFn.mock.callsmockFn.mock.instancesmockFn.mockClear()mockFn.mockImplementation(fn)mockFn.mockImpl(fn)mockFn.mockReturnThis()mockFn.mockReturnValue(value)mockFn.mockReturnValueOnce(value)
Config options
config.bail[boolean]config.cacheDirectory[string]config.collectCoverage[boolean]config.collectCoverageOnlyFrom[object]config.globals[object]config.moduleFileExtensions[array]config.modulePathIgnorePatterns[array]config.rootDir[string]config.scriptPreprocessor[string]config.setupEnvScriptFile[string]config.setupTestFrameworkScriptFile[string]config.testDirectoryName[string]config.testFileExtensions[array]config.testPathDirs[array]config.testPathIgnorePatterns[array]config.testPathPattern[string]config.unmockedModulePathPatterns[array]config.verbose[boolean]
Globally injected variables
afterEach(fn)beforeEach(fn)describe(name, fn)it(name, fn)it.only(name, fn)executes only this test. Useful when investigating a failurejestpit(name, fn)helper for promisesrequire(module)require.requireActual(module)xdescribe(name, fn)xit(name, fn)
expect(value)
.notinverse the next comparison.toThrow(?message).toBe(value)comparison using===.toEqual(value)deep comparison. Usejasmine.any(type)to be softer.toBeFalsy().toBeTruthy().toBeNull().toBeUndefined().toBeDefined().toMatch(regexp).toContain(string).toBeCloseTo(number, delta).toBeGreaterThan(number).toBeLessThan(number).toBeCalled().toBeCalledWith(arg, um, ents).lastCalledWith(arg, um, ents)
<generated_api_end />
0.4.18
10 years ago