@knapsack-pro/jest 8.1.0 → 9.0.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
@@ -47,12 +47,6 @@ See the [docs](https://docs.knapsackpro.com/jest/guide/) to get started:
47
47
 
48
48
  Follow the steps in the [root README.md](https://github.com/KnapsackPro/knapsack-pro-js#contributing) to set up the project.
49
49
 
50
- You can compile TypeScript in watch mode from the root folder with:
51
-
52
- ```bash
53
- npm start -w packages/jest
54
- ```
55
-
56
50
  ### Testing
57
51
 
58
52
  To test `@knapsack-pro/jest` against a real test suite we use:
package/lib/env-config.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvConfig = void 0;
4
- class EnvConfig {
1
+ export class EnvConfig {
5
2
  static loadEnvironmentVariables() {
6
3
  if (process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN_JEST) {
7
4
  process.env.KNAPSACK_PRO_TEST_SUITE_TOKEN =
@@ -24,4 +21,3 @@ class EnvConfig {
24
21
  return process.env.KNAPSACK_PRO_COVERAGE_DIRECTORY;
25
22
  }
26
23
  }
27
- exports.EnvConfig = EnvConfig;
package/lib/jest-cli.js CHANGED
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JestCLI = void 0;
4
- const minimist = require('minimist');
5
- class JestCLI {
1
+ import minimist from 'minimist';
2
+ export class JestCLI {
6
3
  static argvToOptions() {
7
4
  const argv = process.argv.slice(2);
8
5
  return minimist(argv);
9
6
  }
10
7
  }
11
- exports.JestCLI = JestCLI;
@@ -1,30 +1,30 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const core_1 = require("@knapsack-pro/core");
5
- const env_config_1 = require("./env-config");
6
- const test_files_finder_1 = require("./test-files-finder");
7
- const jest_cli_1 = require("./jest-cli");
8
- const jest = require('jest');
9
- const { v4: uuidv4 } = require('uuid');
10
- const { name: clientName, version: clientVersion } = require('../package.json');
11
- const jestCLIOptions = jest_cli_1.JestCLI.argvToOptions();
12
- const knapsackProLogger = new core_1.KnapsackProLogger();
13
- knapsackProLogger.debug(`Jest CLI options:\n${core_1.KnapsackProLogger.objectInspect(jestCLIOptions)}`);
14
- env_config_1.EnvConfig.loadEnvironmentVariables();
2
+ import pkg from '@knapsack-pro/jest/package.json' with { type: 'json' };
3
+ import { KnapsackProCore, KnapsackProLogger, } from '@knapsack-pro/core';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+ import { EnvConfig } from './env-config.js';
6
+ import { TestFilesFinder } from './test-files-finder.js';
7
+ import { JestCLI } from './jest-cli.js';
8
+ const jestImport = await import('jest');
9
+ const jest = jestImport.default ?? jestImport;
10
+ const jestCLIOptions = JestCLI.argvToOptions();
11
+ const knapsackProLogger = new KnapsackProLogger();
12
+ knapsackProLogger.debug(`Jest CLI options:\n${KnapsackProLogger.objectInspect(jestCLIOptions)}`);
13
+ EnvConfig.loadEnvironmentVariables();
15
14
  const projectPath = process.cwd();
16
- const testFilesToExecute = () => test_files_finder_1.TestFilesFinder.allTestFiles();
17
- const knapsackPro = new core_1.KnapsackProCore(clientName, clientVersion, testFilesToExecute);
15
+ const testFilesToExecute = () => TestFilesFinder.allTestFiles();
16
+ const knapsackPro = new KnapsackProCore(pkg.name, pkg.version, testFilesToExecute);
18
17
  const onSuccess = async (queueTestFiles) => {
19
18
  const testFilePaths = queueTestFiles.map((testFile) => testFile.path);
20
- const jestCLICoverage = env_config_1.EnvConfig.coverageDirectory
21
- ? { coverageDirectory: `${env_config_1.EnvConfig.coverageDirectory}/${uuidv4()}` }
19
+ const jestCLICoverage = EnvConfig.coverageDirectory
20
+ ? { coverageDirectory: `${EnvConfig.coverageDirectory}/${uuidv4()}` }
22
21
  : {};
23
22
  const { results: { success: isTestSuiteGreen, testResults }, } = await jest.runCLI({
24
23
  ...jestCLIOptions,
25
24
  ...jestCLICoverage,
26
25
  runTestsByPath: true,
27
26
  _: testFilePaths,
27
+ $0: 'jest',
28
28
  }, [projectPath]);
29
29
  const recordedTestFiles = testResults.map(({ testFilePath, perfStats: { start, end }, }) => {
30
30
  const path = process.platform === 'win32'
@@ -42,5 +42,5 @@ const onSuccess = async (queueTestFiles) => {
42
42
  isTestSuiteGreen,
43
43
  };
44
44
  };
45
- const onError = (error) => { };
45
+ const onError = () => { };
46
46
  knapsackPro.runQueueMode(onSuccess, onError);
@@ -1,41 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.TestFilesFinder = void 0;
27
- const glob_1 = require("glob");
28
- const minimatch_1 = require("minimatch");
29
- const core_1 = require("@knapsack-pro/core");
30
- const env_config_1 = require("./env-config");
31
- const Urls = __importStar(require("./urls"));
32
- class TestFilesFinder {
1
+ import { glob } from 'glob';
2
+ import { minimatch } from 'minimatch';
3
+ import { KnapsackProLogger } from '@knapsack-pro/core';
4
+ import { EnvConfig } from './env-config.js';
5
+ import * as Urls from './urls.js';
6
+ export class TestFilesFinder {
33
7
  static allTestFiles() {
34
- const testFiles = glob_1.glob
35
- .sync(env_config_1.EnvConfig.testFilePattern)
8
+ const testFiles = glob
9
+ .sync(EnvConfig.testFilePattern)
36
10
  .filter((testFilePath) => {
37
- if (env_config_1.EnvConfig.testFileExcludePattern) {
38
- return !(0, minimatch_1.minimatch)(testFilePath, env_config_1.EnvConfig.testFileExcludePattern, {
11
+ if (EnvConfig.testFileExcludePattern) {
12
+ return !minimatch(testFilePath, EnvConfig.testFileExcludePattern, {
39
13
  matchBase: true,
40
14
  });
41
15
  }
@@ -44,7 +18,7 @@ class TestFilesFinder {
44
18
  .filter((testFilePath) => !testFilePath.match(/node_modules/))
45
19
  .map((testFilePath) => ({ path: testFilePath }));
46
20
  if (testFiles.length === 0) {
47
- const knapsackProLogger = new core_1.KnapsackProLogger();
21
+ const knapsackProLogger = new KnapsackProLogger();
48
22
  const errorMessage = `Test files cannot be found.\nPlease set KNAPSACK_PRO_TEST_FILE_PATTERN matching your test directory structure.\nLearn more: ${Urls.NO_TESTS_FOUND}`;
49
23
  knapsackProLogger.error(errorMessage);
50
24
  throw errorMessage;
@@ -52,4 +26,3 @@ class TestFilesFinder {
52
26
  return testFiles;
53
27
  }
54
28
  }
55
- exports.TestFilesFinder = TestFilesFinder;
package/lib/urls.js CHANGED
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NO_TESTS_FOUND = void 0;
4
- exports.NO_TESTS_FOUND = 'https://knapsackpro.com/perma/jest/no-tests-found';
1
+ export const NO_TESTS_FOUND = 'https://knapsackpro.com/perma/jest/no-tests-found';
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@knapsack-pro/jest",
3
- "version": "8.1.0",
3
+ "version": "9.0.0",
4
4
  "description": "Knapsack Pro Jest splits Jest tests across CI nodes and makes sure that tests will run in optimal time on each CI node.",
5
+ "type": "module",
5
6
  "keywords": [
6
7
  "knapsack",
7
8
  "knapsack pro",
@@ -29,13 +30,7 @@
29
30
  ],
30
31
  "license": "MIT",
31
32
  "scripts": {
32
- "start": "nodemon --ext ts --watch src/ --exec \"npm run build\"",
33
- "build": "rm -rf lib && tsc && chmod u+x lib/knapsack-pro-jest.js",
34
- "lint": "npm run eslint:check && npm run prettier:check",
35
- "eslint:check": "eslint . --ext .ts",
36
- "eslint:format": "eslint . --ext .ts --fix",
37
- "prettier:check": "prettier --config .prettierrc.json --check .",
38
- "prettier:format": "prettier --config .prettierrc.json --write ."
33
+ "build": "rm -rf lib && tsc && chmod u+x lib/knapsack-pro-jest.js"
39
34
  },
40
35
  "files": [
41
36
  "/lib"
@@ -51,30 +46,23 @@
51
46
  "bin": {
52
47
  "knapsack-pro-jest": "lib/knapsack-pro-jest.js"
53
48
  },
49
+ "exports": {
50
+ "./package.json": "./package.json"
51
+ },
54
52
  "dependencies": {
55
- "@knapsack-pro/core": "^7.1.0",
56
- "glob": "^10.3.4",
57
- "minimatch": "^9.0.3",
58
- "minimist": "^1.2.6",
59
- "uuid": "^9.0.1"
53
+ "@knapsack-pro/core": "^9.0.0",
54
+ "glob": "^11.0.3",
55
+ "minimatch": "^10.1.1",
56
+ "minimist": "^1.2.8",
57
+ "uuid": "^13.0.0"
60
58
  },
61
59
  "peerDependencies": {
62
- "jest": ">=22.0.0"
60
+ "jest": ">=23.0.0"
63
61
  },
64
62
  "devDependencies": {
65
- "@types/jest": "^29.5.5",
66
- "@types/node": "^20.6.2",
67
- "@typescript-eslint/eslint-plugin": "^6.7.2",
68
- "@typescript-eslint/parser": "^6.7.2",
69
- "eslint": "^8.49.0",
70
- "eslint-config-airbnb-base": "^15.0.0",
71
- "eslint-config-prettier": "^9.0.0",
72
- "eslint-plugin-import": "^2.28.1",
73
- "eslint-plugin-prettier": "^5.0.0",
74
- "jest": "^29.7.0",
75
- "nodemon": "^3.0.1",
76
- "prettier": "^3.0.3",
77
- "ts-jest": "^29.1.1",
78
- "typescript": "^5.2.2"
63
+ "@types/jest": "^30.0.0",
64
+ "@types/node": "^24.9.2",
65
+ "jest": "^30.2.0",
66
+ "typescript": "^5.9.3"
79
67
  }
80
68
  }