@knapsack-pro/jest 5.4.0 → 5.5.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 +97 -102
- package/lib/knapsack-pro-jest.js +4 -2
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
# @knapsack-pro/jest
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://knapsackpro.com?utm_source=github&utm_medium=readme&utm_campaign=knapsack-pro-jest&utm_content=hero_logo">
|
|
5
|
+
<img alt="Knapsack Pro" src="./.github/assets/knapsack.png" width="300" height="300" style="max-width: 100%;" />
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
<h3 align="center">Speed up your tests</h3>
|
|
10
|
+
<p align="center">Run your 1-hour test suite in 2 minutes with optimal parallelisation on your existing CI infrastructure</p>
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
---
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
14
|
+
<div align="center">
|
|
15
|
+
<a href="https://circleci.com/gh/KnapsackPro/knapsack-pro-jest">
|
|
16
|
+
<img alt="Circle CI" src="https://circleci.com/gh/KnapsackPro/knapsack-pro-jest.svg?style=svg" />
|
|
17
|
+
</a>
|
|
18
|
+
</div>
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
13
22
|
|
|
14
|
-
|
|
15
|
-
- [FAQ](#faq)
|
|
16
|
-
- [Development](#development)
|
|
17
|
-
- [Requirements](#requirements)
|
|
18
|
-
- [Dependencies](#dependencies)
|
|
19
|
-
- [Setup](#setup)
|
|
20
|
-
- [Publishing](#publishing)
|
|
21
|
-
- [Testing](#testing)
|
|
22
|
-
- [CI](#ci)
|
|
23
|
-
- [Example Jest test suite](#example-jest-test-suite)
|
|
23
|
+
Knapsack Pro wraps [Jest](https://jestjs.io) and works with your existing CI infrastructure to parallelize tests optimally:
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- Dynamically splits your tests based on up-to-date test execution data
|
|
26
|
+
- Is designed from the ground up for CI and supports all of them
|
|
27
|
+
- Tracks your CI builds to detect bottlenecks
|
|
28
|
+
- Does not have access to your source code and collects minimal test data
|
|
29
|
+
- Enables you to export historical metrics about your CI builds
|
|
30
|
+
- Replaces local dependencies like Redis with an API and runs your tests regardless of network problems
|
|
26
31
|
|
|
27
32
|
## Installation
|
|
28
33
|
|
|
29
34
|
See the [docs](https://docs.knapsackpro.com/jest/guide/) to get started.
|
|
30
35
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
- [FAQ for Knapsack Pro Jest can be found here](https://knapsackpro.com/faq/knapsack_pro_client/knapsack_pro_jest).
|
|
34
|
-
|
|
35
|
-
- This project depends on `@knapsack-pro/core`. Please check the [FAQ for `@knapsack-pro/core`](https://github.com/KnapsackPro/knapsack-pro-core-js#table-of-contents) to learn more about core features available to you.
|
|
36
|
-
|
|
37
|
-
## Development
|
|
36
|
+
## Contributing
|
|
38
37
|
|
|
39
38
|
### Requirements
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
```
|
|
41
|
+
>= Node 18.13.0 LTS
|
|
42
|
+
```
|
|
42
43
|
|
|
43
|
-
-
|
|
44
|
+
You can use [NVM](https://github.com/nvm-sh/nvm) to manage Node versions in development.
|
|
44
45
|
|
|
45
46
|
### Dependencies
|
|
46
47
|
|
|
@@ -48,35 +49,35 @@ You can use [NVM](https://github.com/nvm-sh/nvm) to manage Node version in devel
|
|
|
48
49
|
|
|
49
50
|
### Setup
|
|
50
51
|
|
|
51
|
-
1. Setup [@knapsack-pro/core](https://github.com/KnapsackPro/knapsack-pro-core-js) project.
|
|
52
|
+
1. Setup the [@knapsack-pro/core](https://github.com/KnapsackPro/knapsack-pro-core-js) project.
|
|
52
53
|
|
|
53
|
-
**Follow
|
|
54
|
+
**Follow the steps below or use the `bin/setup_development` script to take care of steps 2-5.**
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
1. Install the dependencies:
|
|
56
57
|
|
|
57
|
-
```
|
|
58
|
-
|
|
58
|
+
```bash
|
|
59
|
+
npm install
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
1. In order to use the local version of `@knapsack-pro/core` run:
|
|
62
63
|
|
|
63
|
-
```
|
|
64
|
-
|
|
64
|
+
```bash
|
|
65
|
+
npm link @knapsack-pro/core
|
|
65
66
|
```
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
1. Compile the TypeScript code to the `lib` directory by running:
|
|
68
69
|
|
|
69
|
-
```
|
|
70
|
-
|
|
70
|
+
```bash
|
|
71
|
+
npm start
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
1. Register the `@knapsack-pro/jest` package globally in your local system. This way we will be able to develop other npm packages dependent on it:
|
|
74
75
|
|
|
75
|
-
```
|
|
76
|
-
|
|
76
|
+
```bash
|
|
77
|
+
npm link
|
|
77
78
|
```
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
1. Set up your IDE:
|
|
80
81
|
|
|
81
82
|
- Visual Studio Code
|
|
82
83
|
|
|
@@ -90,21 +91,34 @@ You can use [NVM](https://github.com/nvm-sh/nvm) to manage Node version in devel
|
|
|
90
91
|
|
|
91
92
|
Turn on `Format On Save` checkbox.
|
|
92
93
|
|
|
93
|
-
From now on, every change in
|
|
94
|
+
From now on, every change in the codebase will be automatically formatted by [Prettier](https://prettier.io/). [ESLint](https://eslint.org/) shows errors and warnings in VSCode.
|
|
95
|
+
|
|
96
|
+
1. Write some code.
|
|
97
|
+
|
|
98
|
+
### Testing
|
|
99
|
+
|
|
100
|
+
#### CI
|
|
101
|
+
|
|
102
|
+
If your feature requires code changes in [@knapsack-pro/core](https://github.com/KnapsackPro/knapsack-pro-core-js), please push the `@knapsack-pro/core` to GitHub first. Then you can push changes for `@knapsack-pro/jest` to ensure the CI will use the latest `@knapsack-pro/core`.
|
|
103
|
+
|
|
104
|
+
#### Example Jest test suite
|
|
105
|
+
|
|
106
|
+
To test `@knapsack-pro/jest` against a real test suite we use:
|
|
94
107
|
|
|
95
|
-
|
|
108
|
+
- [jest-example-test-suite](https://github.com/KnapsackPro/jest-example-test-suite)
|
|
109
|
+
- (deprecated) [react](https://github.com/KnapsackPro/react)
|
|
96
110
|
|
|
97
111
|
### Publishing
|
|
98
112
|
|
|
99
|
-
1. Sign in to npm registry with
|
|
113
|
+
1. Sign in to the npm registry with:
|
|
100
114
|
|
|
101
|
-
```
|
|
102
|
-
|
|
115
|
+
```bash
|
|
116
|
+
npm adduser
|
|
103
117
|
```
|
|
104
118
|
|
|
105
|
-
|
|
119
|
+
1. Ensure you have the latest version of `@knapsack-pro/core` in `package.json`:
|
|
106
120
|
|
|
107
|
-
```
|
|
121
|
+
```bash
|
|
108
122
|
{
|
|
109
123
|
"dependencies": {
|
|
110
124
|
"@knapsack-pro/core": "^x.x.x"
|
|
@@ -112,83 +126,64 @@ You can use [NVM](https://github.com/nvm-sh/nvm) to manage Node version in devel
|
|
|
112
126
|
}
|
|
113
127
|
```
|
|
114
128
|
|
|
115
|
-
|
|
129
|
+
Run `npm install`. This way you will be able to test `@knapsack-pro/core` installed from npm registry instead of the local one that was linked with `npm link @knapsack-pro/core`.
|
|
116
130
|
|
|
117
|
-
|
|
131
|
+
Commit the updated `package.json` and `package-lock.json`:
|
|
118
132
|
|
|
119
|
-
```
|
|
120
|
-
|
|
133
|
+
```bash
|
|
134
|
+
git commit -am "Update @knapsack-pro/core"
|
|
121
135
|
```
|
|
122
136
|
|
|
123
|
-
|
|
137
|
+
1. Before releasing a new version of the package, please update `CHANGELOG.md` with [`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator):
|
|
124
138
|
|
|
125
|
-
```
|
|
126
|
-
|
|
139
|
+
```bash
|
|
140
|
+
gem install github_changelog_generator
|
|
127
141
|
|
|
128
142
|
# generate CHANGELOG.md
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
143
|
+
github_changelog_generator --user KnapsackPro --project knapsack-pro-jest
|
|
144
|
+
git commit -am "Update CHANGELOG.md"
|
|
145
|
+
git push origin master
|
|
132
146
|
```
|
|
133
147
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
5. If you have changed any headers in `README.md` please refresh table of contents with:
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
$ npm run doctoc
|
|
140
|
-
```
|
|
148
|
+
1. If you have added new files to the repository, and they should be part of the released npm package, please ensure they are included in the `files` array in `package.json`.
|
|
141
149
|
|
|
142
|
-
|
|
150
|
+
1. Compile the project:
|
|
143
151
|
|
|
144
|
-
```
|
|
145
|
-
#
|
|
146
|
-
|
|
152
|
+
```bash
|
|
153
|
+
# Ensure you use local version of @knapsack-pro/core
|
|
154
|
+
npm link @knapsack-pro/core
|
|
147
155
|
|
|
148
|
-
|
|
156
|
+
npm run build
|
|
149
157
|
```
|
|
150
158
|
|
|
151
|
-
|
|
159
|
+
1. In order to [bump the version of the package](https://docs.npmjs.com/cli/version) run the command below. It will also create a version commit and tag for the release:
|
|
152
160
|
|
|
153
|
-
```
|
|
154
|
-
#
|
|
155
|
-
|
|
161
|
+
```bash
|
|
162
|
+
# Bump patch version 0.0.x
|
|
163
|
+
npm version patch
|
|
156
164
|
|
|
157
|
-
#
|
|
158
|
-
|
|
165
|
+
# Bump minor version 0.x.0
|
|
166
|
+
npm version minor
|
|
159
167
|
```
|
|
160
168
|
|
|
161
|
-
|
|
169
|
+
1. Push the commit and tag:
|
|
162
170
|
|
|
163
|
-
```
|
|
164
|
-
|
|
171
|
+
```bash
|
|
172
|
+
git push origin master --tags
|
|
165
173
|
```
|
|
166
174
|
|
|
167
|
-
|
|
175
|
+
1. When the git tag is on Github, you can update `CHANGELOG.md`:
|
|
168
176
|
|
|
177
|
+
```bash
|
|
178
|
+
github_changelog_generator --user KnapsackPro --project knapsack-pro-jest
|
|
179
|
+
git commit -am "Update CHANGELOG.md"
|
|
180
|
+
git push origin master
|
|
169
181
|
```
|
|
170
|
-
$ github_changelog_generator --user KnapsackPro --project knapsack-pro-jest
|
|
171
|
-
$ git commit -am "Update CHANGELOG.md"
|
|
172
|
-
$ git push origin master
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
10. Now you can publish package to npm registry:
|
|
176
182
|
|
|
177
|
-
|
|
178
|
-
$ npm publish
|
|
179
|
-
```
|
|
183
|
+
1. Publish the package to the npm registry:
|
|
180
184
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
#### CI
|
|
186
|
-
|
|
187
|
-
If your feature requires code change in [@knapsack-pro/core](https://github.com/KnapsackPro/knapsack-pro-core-js) then please push the `@knapsack-pro/core` to GitHub first. Then you can push changes for `@knapsack-pro/jest` to ensure the CI will use the latest `@knapsack-pro/core`.
|
|
188
|
-
|
|
189
|
-
#### Example Jest test suite
|
|
190
|
-
|
|
191
|
-
To test `@knapsack-pro/jest` against real test suite we use:
|
|
185
|
+
```bash
|
|
186
|
+
npm publish
|
|
187
|
+
```
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
- (deprecated) [react](https://github.com/KnapsackPro/react)
|
|
189
|
+
1. Update the latest available library version in `TestSuiteClientVersionChecker` for the Knapsack Pro API repository.
|
package/lib/knapsack-pro-jest.js
CHANGED
|
@@ -60,8 +60,10 @@ var knapsackProLogger = new core_1.KnapsackProLogger();
|
|
|
60
60
|
knapsackProLogger.debug("Jest CLI options:\n".concat(core_1.KnapsackProLogger.objectInspect(jestCLIOptions)));
|
|
61
61
|
env_config_1.EnvConfig.loadEnvironmentVariables();
|
|
62
62
|
var projectPath = process.cwd();
|
|
63
|
-
var
|
|
64
|
-
|
|
63
|
+
var testFilesToExecute = function () {
|
|
64
|
+
return test_files_finder_1.TestFilesFinder.allTestFiles();
|
|
65
|
+
};
|
|
66
|
+
var knapsackPro = new core_1.KnapsackProCore(clientName, clientVersion, testFilesToExecute);
|
|
65
67
|
var onSuccess = function (queueTestFiles) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
68
|
var testFilePaths, jestCLICoverage, _a, isTestSuiteGreen, testResults, recordedTestFiles;
|
|
67
69
|
return __generator(this, function (_b) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knapsack-pro/jest",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.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
5
|
"keywords": [
|
|
6
6
|
"knapsack",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"eslint:check": "eslint . --ext .ts",
|
|
36
36
|
"eslint:format": "eslint . --ext .ts --fix",
|
|
37
37
|
"prettier:check": "prettier --check .",
|
|
38
|
-
"prettier:format": "prettier --config .prettierrc.json 'src/**/*.ts' --write"
|
|
39
|
-
"doctoc": "doctoc --title \"## Table of Contents\" README.md"
|
|
38
|
+
"prettier:format": "prettier --config .prettierrc.json 'src/**/*.ts' --write"
|
|
40
39
|
},
|
|
41
40
|
"files": [
|
|
42
41
|
"/lib"
|
|
@@ -53,35 +52,34 @@
|
|
|
53
52
|
"knapsack-pro-jest": "lib/knapsack-pro-jest.js"
|
|
54
53
|
},
|
|
55
54
|
"dependencies": {
|
|
56
|
-
"@knapsack-pro/core": "^
|
|
55
|
+
"@knapsack-pro/core": "^4.0.0",
|
|
57
56
|
"glob": "^8.0.3",
|
|
58
57
|
"minimatch": "^5.1.0",
|
|
59
58
|
"minimist": "^1.2.6",
|
|
60
59
|
"uuid": "^8.3.2"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
63
|
-
"jest": ">=22.0.0
|
|
62
|
+
"jest": ">=22.0.0"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
65
|
"@babel/core": "^7.18.2",
|
|
67
66
|
"@babel/preset-env": "^7.18.2",
|
|
68
67
|
"@babel/register": "^7.17.7",
|
|
69
|
-
"@types/jest": "^28.1.1",
|
|
70
68
|
"@types/glob": "^7.2.0",
|
|
69
|
+
"@types/jest": "^28.1.1",
|
|
71
70
|
"@types/node": "^17.0.41",
|
|
72
71
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
73
72
|
"@typescript-eslint/parser": "^5.27.1",
|
|
74
73
|
"del": "^6.1.1",
|
|
75
|
-
"doctoc": "^2.2.0",
|
|
76
74
|
"eslint": "^7.32.0",
|
|
77
75
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
78
76
|
"eslint-config-prettier": "^8.5.0",
|
|
79
77
|
"eslint-plugin-import": "^2.26.0",
|
|
80
78
|
"eslint-plugin-prettier": "^4.0.0",
|
|
81
79
|
"gulp": "^4.0.2",
|
|
82
|
-
"gulp-typescript": "^5.0.1",
|
|
83
80
|
"gulp-chmod": "^3.0.0",
|
|
84
81
|
"gulp-filter": "^7.0.0",
|
|
82
|
+
"gulp-typescript": "^5.0.1",
|
|
85
83
|
"jest": "^28.1.0",
|
|
86
84
|
"prettier": "^2.6.2",
|
|
87
85
|
"ts-jest": "^28.0.4",
|