@html-validate/jest-config 3.9.0 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,6 +29,14 @@ In your `package.json` file:
29
29
  }
30
30
  ```
31
31
 
32
+ ### Presets
33
+
34
+ | Preset | Description |
35
+ | ------------------------------------------ | ------------------------- |
36
+ | @html-validate/jest-config | Alias for presets/default |
37
+ | @html-validate/jest-config/presets/default | Default preset |
38
+ | @html-validate/jest-config/presets/esm | Experimental ESM support |
39
+
32
40
  ### Transpiling ESM in `node_modules/`
33
41
 
34
42
  If you need to import and use ESM-only libraries you need to install `@babel/core.
package/jest-preset.js CHANGED
@@ -1,88 +1 @@
1
- const { version: tsjestVersion } = require("ts-jest/package.json");
2
- const { detectBabel, findTsConfig } = require("./lib");
3
-
4
- const cwd = process.cwd();
5
- const tsjestMajor = parseInt(tsjestVersion.split(".")[0], 10);
6
- const useLegacyTsJestConfig = tsjestMajor < 29;
7
-
8
- const tsjestOptions = {
9
- stringifyContentPathRegex: "\\.html?$",
10
- tsconfig: findTsConfig(cwd),
11
- };
12
-
13
- const preset = {
14
- collectCoverage: true,
15
- collectCoverageFrom: [
16
- "src/**/*.[jt]s",
17
- "packages/*/*src/**/*.[jt]s",
18
- "!**/*.spec.[jt]s",
19
- "!**/*.d.ts",
20
- "!**/index.[jt]s",
21
- "!**/__fixtures__/**",
22
- "!**/generated/**",
23
- ],
24
- coverageReporters: ["text", "text-summary", "cobertura", "html", "json", "lcov"],
25
-
26
- /* until jest 30 we must force prettier 2 or formatting snapshots wont work */
27
- prettierPath: require.resolve("prettier-2"),
28
-
29
- reporters: [
30
- "default",
31
- [
32
- require.resolve("jest-junit"),
33
- {
34
- outputDirectory: "temp",
35
- outputName: "./jest.xml",
36
- },
37
- ],
38
- ],
39
- snapshotFormat: {
40
- escapeString: false,
41
- printBasicPrototype: false,
42
- },
43
- snapshotSerializers: [require.resolve("jest-serializer-ansi-escapes")],
44
- testEnvironmentOptions: {
45
- customExportConditions: ["node"],
46
- },
47
- testPathIgnorePatterns: [
48
- "/node_modules/",
49
- "<rootDir>/build/",
50
- "<rootDir>/dist/",
51
- "<rootDir>/cypress/",
52
- "<rootDir>/packages/.*/dist/",
53
- ],
54
- testRegex: "(/__tests__/.+|(\\.|/)(test|spec))\\.[jt]s$",
55
- };
56
-
57
- if (useLegacyTsJestConfig) {
58
- preset.globals = {
59
- "ts-jest": tsjestOptions,
60
- };
61
- preset.transform = {
62
- "^.+\\.(tsx?|html)$": require.resolve("ts-jest"),
63
- };
64
- } else {
65
- preset.transform = {
66
- "^.+\\.(tsx?|html)$": [require.resolve("ts-jest"), tsjestOptions],
67
- };
68
- }
69
-
70
- if (detectBabel()) {
71
- preset.transformIgnorePatterns = [];
72
- preset.transform["^.+\\.m?js$"] = [
73
- require.resolve("babel-jest"),
74
- {
75
- plugins: [
76
- [require.resolve("babel-plugin-transform-import-meta"), { module: "ES6" }],
77
- require.resolve("@babel/plugin-transform-modules-commonjs"),
78
- ],
79
- },
80
- ];
81
- }
82
-
83
- if (require.main === module) {
84
- /* eslint-disable-next-line no-console */
85
- console.log(JSON.stringify(preset, null, 2));
86
- }
87
-
88
- module.exports = preset;
1
+ module.exports = require("./presets/default/jest-preset");
package/lib/common.js ADDED
@@ -0,0 +1,45 @@
1
+ const commonConfig = {
2
+ collectCoverage: true,
3
+ collectCoverageFrom: [
4
+ "src/**/*.[jt]s",
5
+ "packages/*/*src/**/*.[jt]s",
6
+ "!**/*.spec.[jt]s",
7
+ "!**/*.d.ts",
8
+ "!**/index.[jt]s",
9
+ "!**/__fixtures__/**",
10
+ "!**/generated/**",
11
+ ],
12
+ coverageReporters: ["text", "text-summary", "cobertura", "html", "json", "lcov"],
13
+
14
+ /* until jest 30 we must force prettier 2 or formatting snapshots wont work */
15
+ prettierPath: require.resolve("prettier-2"),
16
+
17
+ reporters: [
18
+ "default",
19
+ [
20
+ require.resolve("jest-junit"),
21
+ {
22
+ outputDirectory: "temp",
23
+ outputName: "./jest.xml",
24
+ },
25
+ ],
26
+ ],
27
+ snapshotFormat: {
28
+ escapeString: false,
29
+ printBasicPrototype: false,
30
+ },
31
+ snapshotSerializers: [require.resolve("jest-serializer-ansi-escapes")],
32
+ testEnvironmentOptions: {
33
+ customExportConditions: ["node"],
34
+ },
35
+ testPathIgnorePatterns: [
36
+ "/node_modules/",
37
+ "<rootDir>/build/",
38
+ "<rootDir>/dist/",
39
+ "<rootDir>/cypress/",
40
+ "<rootDir>/packages/.*/dist/",
41
+ ],
42
+ testRegex: "(/__tests__/.+|(\\.|/)(test|spec))\\.[jt]s$",
43
+ };
44
+
45
+ module.exports = { commonConfig };
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
+ const { commonConfig } = require("./common");
1
2
  const { detectBabel } = require("./detect-babel");
2
3
  const { findTsConfig } = require("./find-ts-config");
3
4
 
4
- module.exports = { detectBabel, findTsConfig };
5
+ module.exports = { commonConfig, detectBabel, findTsConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/jest-config",
3
- "version": "3.9.0",
3
+ "version": "3.10.0",
4
4
  "description": "Jest sharable preset used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "jest"
@@ -20,10 +20,11 @@
20
20
  "files": [
21
21
  "dist",
22
22
  "lib",
23
+ "presets",
23
24
  "jest-preset.js"
24
25
  ],
25
26
  "dependencies": {
26
- "@babel/plugin-transform-modules-commonjs": "7.23.3",
27
+ "@babel/plugin-transform-modules-commonjs": "7.24.1",
27
28
  "babel-plugin-transform-import-meta": "2.2.1",
28
29
  "jest-junit": "16.0.0",
29
30
  "jest-serializer-ansi-escapes": "3.0.0",
@@ -0,0 +1,46 @@
1
+ const { version: tsjestVersion } = require("ts-jest/package.json");
2
+ const { commonConfig, detectBabel, findTsConfig } = require("../../lib");
3
+
4
+ const cwd = process.cwd();
5
+ const tsjestMajor = parseInt(tsjestVersion.split(".")[0], 10);
6
+ const useLegacyTsJestConfig = tsjestMajor < 29;
7
+
8
+ const tsjestOptions = {
9
+ stringifyContentPathRegex: "\\.html?$",
10
+ tsconfig: findTsConfig(cwd),
11
+ };
12
+
13
+ const preset = { ...commonConfig };
14
+
15
+ if (useLegacyTsJestConfig) {
16
+ preset.globals = {
17
+ "ts-jest": tsjestOptions,
18
+ };
19
+ preset.transform = {
20
+ "^.+\\.(tsx?|html)$": require.resolve("ts-jest"),
21
+ };
22
+ } else {
23
+ preset.transform = {
24
+ "^.+\\.(tsx?|html)$": [require.resolve("ts-jest"), tsjestOptions],
25
+ };
26
+ }
27
+
28
+ if (detectBabel()) {
29
+ preset.transformIgnorePatterns = [];
30
+ preset.transform["^.+\\.m?js$"] = [
31
+ require.resolve("babel-jest"),
32
+ {
33
+ plugins: [
34
+ [require.resolve("babel-plugin-transform-import-meta"), { module: "ES6" }],
35
+ require.resolve("@babel/plugin-transform-modules-commonjs"),
36
+ ],
37
+ },
38
+ ];
39
+ }
40
+
41
+ if (require.main === module) {
42
+ /* eslint-disable-next-line no-console */
43
+ console.log(JSON.stringify(preset, null, 2));
44
+ }
45
+
46
+ module.exports = preset;
@@ -0,0 +1,24 @@
1
+ const { commonConfig, findTsConfig } = require("../../lib");
2
+
3
+ const cwd = process.cwd();
4
+
5
+ const tsjestOptions = {
6
+ stringifyContentPathRegex: "\\.html?$",
7
+ tsconfig: findTsConfig(cwd),
8
+ useESM: true,
9
+ };
10
+
11
+ const preset = {
12
+ ...commonConfig,
13
+ extensionsToTreatAsEsm: [".ts", ".tsx", ".mts"],
14
+ transform: {
15
+ "^.+\\.(tsx?|html)$": [require.resolve("ts-jest"), tsjestOptions],
16
+ },
17
+ };
18
+
19
+ if (require.main === module) {
20
+ /* eslint-disable-next-line no-console */
21
+ console.log(JSON.stringify(preset, null, 2));
22
+ }
23
+
24
+ module.exports = preset;