@html-validate/jest-config
Jest sharable preset used by the various HTML-validate packages
- Static
- Latest Patch
- Latest Minor
- Latest Major
- 3.13.0
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.2
- 3.11.1
- 3.11.0
- 3.10.0
- 3.9.0
- 3.8.0
- 3.7.7
- 3.7.6
- 3.7.5
- 3.7.4
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.3
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.0
- 2.1.0
- 2.0.0
- 1.2.10
- 1.2.9
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.34
- 1.0.33
- 1.0.32
- 1.0.31
- 1.0.30
- 1.0.29
- 1.0.28
- 1.0.27
- 1.0.26
- 1.0.25
- 1.0.24
- 1.0.23
- 1.0.22
- 1.0.21
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
@html-validate/jest-config
HTML-Validate jest preset.
Jest is configured to:
- Run tests from
*.spec.[jt]s
. - Collect coverage from
.js
and.ts
insrc
and ignore tests (**/*.spec.[jt]s
) and index (**/index.[jt]s
). - Report results as junit in
temp/jest.xml
. - Transform typescript with
ts-jest
. - Transform js with
babel-jest
if babel is detected. - Ignores spec-files from Cypress.
Install
npm install --save-dev @html-validate/jest-config
Usage
In your package.json
file:
{
"jest": {
"preset": "@html-validate/jest-config"
}
}
Presets
Preset | Description |
---|---|
@html-validate/jest-config | Alias for presets/default |
@html-validate/jest-config/presets/default | Default preset |
@html-validate/jest-config/presets/esm | Experimental ESM support |
Transpiling ESM in node_modules/
If you need to import and use ESM-only libraries you need to install @babel/core. You do not need a
babel.config.jsor
.babelrcas the preset passes the required configuration directly to
babel-jest`.
npm install --save-dev @babel/core
When babel is detect the preset sets transformIgnorePatterns
to transpile everything under node_modules
.
You can include a more specific list of packages to transform (potential speed gain) by manually setting transformIgnorePatterns
:
Optionally you can set transformIgnorePatterns
in package.json
:
{
"jest": {
"preset": "@html-validate/jest-config",
+ "transformIgnorePatterns": ["node_modules/(?!(foo|bar|baz)/)"]
}
}
This will transform only the foo
, bar
and baz
packages.
Importing HTML as string
Importing *.html
is supported by jest configuration but requires additional typescript config by creating a declaration:
shim-html.d.ts
:
declare module "*.html" {
const value: string;
export default value;
}
tsconfig.json
This preset searches the project folder for typescript configuration in the following order:
tsconfig.jest.json
tsconfig.json