Unit and Snapshot Testing
via Jest
The sku test command will invoke Jest, running any tests in files named *.test.js, *.spec.js or in a __tests__ folder.
Since sku uses Jest as a testing framework, you can read the Jest documentation for more information on writing compatible tests.
Note: sku will forward all command line args to jest.
Example running tests in watch mode:
$ sku test --watchIf you need to set up your test framework, you can provide a setupTests script in your config:
export default {
setupTests: 'src/setupTests.ts',
} satisfies SkuConfig;For example, if you're using React Testing Library and wish to use the custom jest matchers provided by @testing-library/jest-dom, your setupTests script would look like this:
import '@testing-library/jest-dom';sku's Jest configuration can also be used as a preset:
/** @type {import('jest').Config} */
module.exports = {
preset: 'sku',
};This enables debugging tests in VS Code using the Jest extension, by following the instructions in the Jest documentation.
