@growflow/jest
v10.1.0
Published
Shareable Jest configuration to get testing up and running quickly for GrowFlow frontend and backend applications
Downloads
3,025
Readme
GrowFlow Jest Configuration
Shareable Jest configuration to get testing up and running quickly for GrowFlow frontend and backend applications.
Usage
yarn add --dev @growflow/jestYou can then create a jest.config.ts file in your project root:
import { createJestConfig } from '@growflow/jest';
export default createJestConfig();For a frontend app, you can use createUiJestConfig:
import { createUiJestConfig } from '@growflow/jest';
export default createUiJestConfig();Customization
You can override any part of the jest config by passing a partial configuration object to be deep merged with the base config:
import { createUiJestConfig } from '@growflow/jest';
export default createUiJestConfig({
rootDir: '../',
testPathIgnorePatterns: ['./test/ignorme.tsx'],
});TS Auto Mock
The base configuration can automatically configure TS Auto Mock. In order for this to work, it has to switch the compilation of the tests to TTypeScript (notice the extra T).
For this reason, TS Auto Mock support is opt-in:
import { createJestConfig } from '@growflow/jest';
export default createJestConfig({ includeTsAutoMock: true });Writing Tests
This jest configuration will run tests given a number of different styles:
- Run tests in a
testfolder adjacent to thesrcfolder. - Run tests in a
__test__or__tests__folder anywhere in the workspace. - Run tests in a
file.spec.tsorfile.test.jsfile adjacent to the SUT.
To match GrowFlow's style, in general, integration-like tests should go into a test folder adjacent to src. Unit-style tests should go in a __tests__ folder or a file.test.ts file next to the file it is testing.
