PixelOven.Test

Overview

NOTICE: This feature will be removed from the core cli and become an addon in a future update.

Test is a simple wrapper for testing JavaScript applications. It currently acts as proxy for the Jest compiler and comes with a dependecies to make it more compatible with TypeScript.

Jest

It is important to note that currently this feature expects a jest.json file to be present at the root of the package to configure the compiler.

For reference on all the available configurations please review the official documentation for Jest.

Setup

First be sure to create a jest.json file at the root of the project or in other words adjacent to the package.json.

{
"bail": true,
"collectCoverageFrom": [
"!<rootDir>/**/*.stories.{js,jsx,ts,tsx}",
"!<rootDir>/**/*.test.{js,jsx,ts,tsx}",
"<rootDir>/**/*.{js,jsx,ts,tsx}"
],
"coverageDirectory": "<rootDir>/../coverage",
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
},
"moduleFileExtensions": ["js", "json", "jsx", "ts", "tsx"],
"preset": "ts-jest",
"rootDir": "./src",
"testEnvironment": "node",
"testMatch": ["<rootDir>/**/*.test.(j|t)s?(x)"],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$"
],
"verbose": true
}

Options

For reference on all the available options please review the official documentation for Jest.

Usage

Once this has been confirmed all we have to do is run the following.

yarn run pixeloven test --watch

or perhaps as part of a CI workflow:

yarn run pixeloven test --ci --coverage

Jest has an extensive CLI and so it is recommended to review their documentation for all the available options. Proper configuration through jest.json is also highly recommended.

Last updated on by Brian Gebel