@universal-packages/sub-process-jest
v1.1.6
Published
Jest matchers for Universal Sub Process
Downloads
2,487
Readme
Sub-Process Jest
Jest matchers for SubProcess testing.
Install
npm install @universal-packages/sub-process-jest
npm install @universal-packages/sub-process
Setup
Add the following to your jest.config.js
or where you configure Jest:
module.exports = {
setupFilesAfterEnv: ['@universal-packages/sub-process-jest']
}
Matchers
toHaveRun
import { SubProcess } from '@universal-packages/sub-process'
it('should logged log', async () => {
const subProcess = new SubProcess({ command: 'echo', args: ['Hello World'] })
await subProcess.run()
expect(SubProcess).toHaveRun({ command: 'echo', args: ['Hello World'] })
expect(SubProcess).toHaveRun('echo Hello World')
})
toHaveRunTotal
import { SubProcess } from '@universal-packages/sub-process'
it('should run a total number of commands', async () => {
const subProcess = new SubProcess({ command: 'echo', args: ['Hello World'] })
await subProcess.run()
expect(SubProcess).toHaveRunTotal(1)
})
Typescript
In order for typescript to see the global types you need to reference the types somewhere in your project, normally ./src/globals.d.ts
.
/// <reference types="@universal-packages/sub-process-jest" />
This library is developed in TypeScript and shipped fully typed.
Contributing
The development of this library happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving this library.