@growflow/jest
v10.1.0
Published
Shareable Jest configuration to get testing up and running quickly for GrowFlow frontend and backend applications
Downloads
1,546
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/jest
You 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
test
folder adjacent to thesrc
folder. - Run tests in a
__test__
or__tests__
folder anywhere in the workspace. - Run tests in a
file.spec.ts
orfile.test.js
file 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.