@servicetitan/startup 31.5.1 → 32.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/dist/cli/commands/build.d.ts +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/bundle-package.d.ts +1 -1
- package/dist/cli/commands/bundle-package.d.ts.map +1 -1
- package/dist/cli/commands/bundle-package.js.map +1 -1
- package/dist/cli/commands/eslint.d.ts +1 -1
- package/dist/cli/commands/eslint.d.ts.map +1 -1
- package/dist/cli/commands/eslint.js.map +1 -1
- package/dist/cli/commands/get-command.js +2 -2
- package/dist/cli/commands/get-command.js.map +1 -1
- package/dist/cli/commands/index.d.ts +1 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -1
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +3 -2
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +24 -43
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/install.d.ts +4 -0
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +91 -3
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/lint.d.ts +1 -1
- package/dist/cli/commands/lint.d.ts.map +1 -1
- package/dist/cli/commands/lint.js.map +1 -1
- package/dist/cli/commands/mfe-package-clean.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-clean.js +5 -7
- package/dist/cli/commands/mfe-package-clean.js.map +1 -1
- package/dist/cli/commands/mfe-package-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-package-publish.js +11 -15
- package/dist/cli/commands/mfe-package-publish.js.map +1 -1
- package/dist/cli/commands/mfe-publish.d.ts +1 -1
- package/dist/cli/commands/mfe-publish.d.ts.map +1 -1
- package/dist/cli/commands/mfe-publish.js.map +1 -1
- package/dist/cli/commands/prepare-package.d.ts +1 -1
- package/dist/cli/commands/prepare-package.d.ts.map +1 -1
- package/dist/cli/commands/prepare-package.js.map +1 -1
- package/dist/cli/commands/review/rules/index.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/index.js +4 -0
- package/dist/cli/commands/review/rules/index.js.map +1 -1
- package/dist/cli/commands/review/rules/require-all-react-dependencies.d.ts +14 -0
- package/dist/cli/commands/review/rules/require-all-react-dependencies.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-all-react-dependencies.js +64 -0
- package/dist/cli/commands/review/rules/require-all-react-dependencies.js.map +1 -0
- package/dist/cli/commands/review/rules/require-one-react-version.d.ts +5 -0
- package/dist/cli/commands/review/rules/require-one-react-version.d.ts.map +1 -0
- package/dist/cli/commands/review/rules/require-one-react-version.js +25 -0
- package/dist/cli/commands/review/rules/require-one-react-version.js.map +1 -0
- package/dist/cli/commands/review/rules/require-one-uikit-version.d.ts.map +1 -1
- package/dist/cli/commands/review/rules/require-one-uikit-version.js +1 -0
- package/dist/cli/commands/review/rules/require-one-uikit-version.js.map +1 -1
- package/dist/cli/commands/review/utils/format-depends-on.d.ts +1 -0
- package/dist/cli/commands/review/utils/format-depends-on.d.ts.map +1 -1
- package/dist/cli/commands/review/utils/format-depends-on.js +15 -8
- package/dist/cli/commands/review/utils/format-depends-on.js.map +1 -1
- package/dist/cli/commands/review/utils/set-version.d.ts +2 -1
- package/dist/cli/commands/review/utils/set-version.d.ts.map +1 -1
- package/dist/cli/commands/review/utils/set-version.js +4 -2
- package/dist/cli/commands/review/utils/set-version.js.map +1 -1
- package/dist/cli/commands/start.d.ts +1 -1
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/test/index.d.ts +2 -0
- package/dist/cli/commands/test/index.d.ts.map +1 -0
- package/dist/cli/commands/test/index.js +20 -0
- package/dist/cli/commands/test/index.js.map +1 -0
- package/dist/cli/commands/test/runners/index.d.ts +3 -0
- package/dist/cli/commands/test/runners/index.d.ts.map +1 -0
- package/dist/cli/commands/test/runners/index.js +21 -0
- package/dist/cli/commands/test/runners/index.js.map +1 -0
- package/dist/cli/commands/test/runners/jest.d.ts +7 -0
- package/dist/cli/commands/test/runners/jest.d.ts.map +1 -0
- package/dist/cli/commands/test/runners/jest.js +43 -0
- package/dist/cli/commands/test/runners/jest.js.map +1 -0
- package/dist/cli/commands/test/runners/vitest.d.ts +4 -0
- package/dist/cli/commands/test/runners/vitest.d.ts.map +1 -0
- package/dist/cli/commands/test/runners/vitest.js +86 -0
- package/dist/cli/commands/test/runners/vitest.js.map +1 -0
- package/dist/cli/commands/test/tests.d.ts +18 -0
- package/dist/cli/commands/test/tests.d.ts.map +1 -0
- package/dist/cli/commands/{tests.js → test/tests.js} +10 -9
- package/dist/cli/commands/test/tests.js.map +1 -0
- package/dist/cli/commands/upload-sourcemaps.d.ts.map +1 -1
- package/dist/cli/commands/upload-sourcemaps.js +1 -1
- package/dist/cli/commands/upload-sourcemaps.js.map +1 -1
- package/dist/cli/index.js +1 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/bundle.d.ts.map +1 -1
- package/dist/cli/utils/bundle.js +7 -4
- package/dist/cli/utils/bundle.js.map +1 -1
- package/dist/cli/utils/cli-git.d.ts +11 -2
- package/dist/cli/utils/cli-git.d.ts.map +1 -1
- package/dist/cli/utils/cli-git.js +60 -4
- package/dist/cli/utils/cli-git.js.map +1 -1
- package/dist/cli/utils/index.d.ts +6 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +6 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/is-ci.d.ts +2 -0
- package/dist/cli/utils/is-ci.d.ts.map +1 -0
- package/dist/cli/utils/is-ci.js +15 -0
- package/dist/cli/utils/is-ci.js.map +1 -0
- package/dist/cli/utils/lerna-exec.d.ts.map +1 -1
- package/dist/cli/utils/lerna-exec.js +2 -1
- package/dist/cli/utils/lerna-exec.js.map +1 -1
- package/dist/cli/utils/set-node-options.d.ts.map +1 -1
- package/dist/cli/utils/set-node-options.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/get-branch-configs.d.ts +1 -1
- package/dist/utils/get-branch-configs.d.ts.map +1 -1
- package/dist/utils/get-branch-configs.js +2 -2
- package/dist/utils/get-branch-configs.js.map +1 -1
- package/dist/utils/get-configuration.d.ts +8 -2
- package/dist/utils/get-configuration.d.ts.map +1 -1
- package/dist/utils/get-configuration.js +10 -2
- package/dist/utils/get-configuration.js.map +1 -1
- package/dist/utils/get-jest-config.d.ts +1 -7
- package/dist/utils/get-jest-config.d.ts.map +1 -1
- package/dist/utils/get-jest-config.js +49 -58
- package/dist/utils/get-jest-config.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/webpack/utils/testing/get-compiler.js.map +1 -1
- package/package.json +16 -14
- package/src/cli/commands/__tests__/init.test.ts +21 -87
- package/src/cli/commands/__tests__/install.test.ts +174 -12
- package/src/cli/commands/__tests__/mfe-package-clean.test.ts +3 -6
- package/src/cli/commands/__tests__/mfe-package-publish.test.ts +6 -8
- package/src/cli/commands/__tests__/upload-sourcemaps.test.ts +7 -3
- package/src/cli/commands/build.ts +1 -1
- package/src/cli/commands/bundle-package.ts +1 -1
- package/src/cli/commands/eslint.ts +1 -1
- package/src/cli/commands/get-command.ts +1 -1
- package/src/cli/commands/index.ts +1 -1
- package/src/cli/commands/init.ts +18 -38
- package/src/cli/commands/install.ts +95 -6
- package/src/cli/commands/lint.ts +1 -1
- package/src/cli/commands/mfe-package-clean.ts +2 -4
- package/src/cli/commands/mfe-package-publish.ts +18 -6
- package/src/cli/commands/mfe-publish.ts +1 -1
- package/src/cli/commands/prepare-package.ts +1 -1
- package/src/cli/commands/review/rules/__tests__/require-all-react-dependencies.test.ts +132 -0
- package/src/cli/commands/review/rules/__tests__/require-one-package-version.test.ts +0 -1
- package/src/cli/commands/review/rules/__tests__/require-one-react-version.test.ts +22 -0
- package/src/cli/commands/review/rules/__tests__/{require-one-uikit-version.ts → require-one-uikit-version.test.ts} +1 -0
- package/src/cli/commands/review/rules/index.ts +4 -0
- package/src/cli/commands/review/rules/require-all-react-dependencies.ts +53 -0
- package/src/cli/commands/review/rules/require-one-react-version.ts +9 -0
- package/src/cli/commands/review/rules/require-one-uikit-version.ts +1 -0
- package/src/cli/commands/review/utils/__tests__/set-version.test.ts +18 -8
- package/src/cli/commands/review/utils/format-depends-on.ts +8 -5
- package/src/cli/commands/review/utils/set-version.ts +10 -2
- package/src/cli/commands/start.ts +1 -1
- package/src/cli/commands/test/__tests__/tests.test.ts +78 -0
- package/src/cli/commands/test/index.ts +1 -0
- package/src/cli/commands/{__tests__/tests.test.ts → test/runners/__tests__/jest.test.ts} +10 -13
- package/src/cli/commands/test/runners/__tests__/vitest.test.ts +150 -0
- package/src/cli/commands/test/runners/index.ts +2 -0
- package/src/cli/commands/{tests.ts → test/runners/jest.ts} +5 -16
- package/src/cli/commands/test/runners/vitest.ts +70 -0
- package/src/cli/commands/test/tests.ts +34 -0
- package/src/cli/commands/upload-sourcemaps.ts +2 -2
- package/src/cli/index.ts +1 -2
- package/src/cli/utils/__tests__/bundle.test.ts +1 -1
- package/src/cli/utils/__tests__/cli-git.test.ts +142 -6
- package/src/cli/utils/__tests__/eslint.test.ts +3 -2
- package/src/cli/utils/__tests__/is-ci.test.ts +40 -0
- package/src/cli/utils/__tests__/lerna-exec.test.ts +6 -3
- package/src/cli/utils/bundle.ts +8 -3
- package/src/cli/utils/cli-git.ts +55 -5
- package/src/cli/utils/index.ts +6 -0
- package/src/cli/utils/is-ci.ts +3 -0
- package/src/cli/utils/lerna-exec.ts +2 -1
- package/src/cli/utils/set-node-options.ts +2 -2
- package/src/index.ts +0 -1
- package/src/utils/__tests__/get-configuration.test.ts +48 -11
- package/src/utils/__tests__/get-jest-config.test.ts +35 -61
- package/src/utils/get-branch-configs.ts +1 -1
- package/src/utils/get-configuration.ts +14 -3
- package/src/utils/get-jest-config.ts +39 -47
- package/src/utils/index.ts +1 -0
- package/src/webpack/__tests__/create-webpack-config-shared-dependencies.test.ts +1 -1
- package/src/webpack/__tests__/create-webpack-config-web-component.test.ts +1 -1
- package/src/webpack/__tests__/create-webpack-config.test.ts +1 -1
- package/src/webpack/utils/testing/get-compiler.ts +1 -1
- package/dist/cli/commands/tests.d.ts +0 -13
- package/dist/cli/commands/tests.d.ts.map +0 -1
- package/dist/cli/commands/tests.js.map +0 -1
- package/dist/jest/index.d.ts +0 -2
- package/dist/jest/index.d.ts.map +0 -1
- package/dist/jest/index.js +0 -16
- package/dist/jest/index.js.map +0 -1
- package/src/jest/index.ts +0 -5
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
getJestConfiguration,
|
|
9
9
|
getReviewConfiguration,
|
|
10
10
|
getStylelintConfiguration,
|
|
11
|
+
getVitestConfiguration,
|
|
11
12
|
getWebComponentBranchConfigs,
|
|
12
13
|
getWebComponentConfiguration,
|
|
13
14
|
hasHeadlessBundle,
|
|
@@ -43,8 +44,8 @@ describe('[startup] Utils', () => {
|
|
|
43
44
|
|
|
44
45
|
afterEach(() => jest.resetAllMocks());
|
|
45
46
|
|
|
46
|
-
describe(
|
|
47
|
-
let locationOrJson:
|
|
47
|
+
describe(getConfiguration.name, () => {
|
|
48
|
+
let locationOrJson: Parameters<typeof getConfiguration>[0];
|
|
48
49
|
|
|
49
50
|
beforeEach(() => (locationOrJson = undefined));
|
|
50
51
|
|
|
@@ -94,7 +95,7 @@ describe('[startup] Utils', () => {
|
|
|
94
95
|
});
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
describe(
|
|
98
|
+
describe(getConfigurationSafe.name, () => {
|
|
98
99
|
let locationOrJson: string | Record<string, any> | undefined;
|
|
99
100
|
|
|
100
101
|
beforeEach(() => (locationOrJson = undefined));
|
|
@@ -141,7 +142,7 @@ describe('[startup] Utils', () => {
|
|
|
141
142
|
});
|
|
142
143
|
});
|
|
143
144
|
|
|
144
|
-
describe(
|
|
145
|
+
describe(getESLintConfiguration.name, () => {
|
|
145
146
|
const subject = () => getESLintConfiguration();
|
|
146
147
|
|
|
147
148
|
itReturns(subject, {});
|
|
@@ -157,7 +158,7 @@ describe('[startup] Utils', () => {
|
|
|
157
158
|
});
|
|
158
159
|
});
|
|
159
160
|
|
|
160
|
-
describe(
|
|
161
|
+
describe(getJestConfiguration.name, () => {
|
|
161
162
|
const subject = () => getJestConfiguration();
|
|
162
163
|
|
|
163
164
|
itReturns(subject, {});
|
|
@@ -171,9 +172,29 @@ describe('[startup] Utils', () => {
|
|
|
171
172
|
expect(subject()).toEqual(content.cli.test);
|
|
172
173
|
});
|
|
173
174
|
});
|
|
175
|
+
|
|
176
|
+
describe('with "cli.jest"', () => {
|
|
177
|
+
const content = { cli: { jest: { baz: 'qux' } } };
|
|
178
|
+
|
|
179
|
+
beforeEach(() => mockPackageJson(content));
|
|
180
|
+
|
|
181
|
+
test('returns "cli.jest"', () => {
|
|
182
|
+
expect(subject()).toEqual(content.cli.jest);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe('with both "cli.test" and "cli.jest"', () => {
|
|
187
|
+
const content = { cli: { test: { foo: 'bar' }, jest: { baz: 'qux' } } };
|
|
188
|
+
|
|
189
|
+
beforeEach(() => mockPackageJson(content));
|
|
190
|
+
|
|
191
|
+
test('returns "cli.jest"', () => {
|
|
192
|
+
expect(subject()).toEqual(content.cli.jest);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
174
195
|
});
|
|
175
196
|
|
|
176
|
-
describe(
|
|
197
|
+
describe(getReviewConfiguration.name, () => {
|
|
177
198
|
const subject = () => getReviewConfiguration();
|
|
178
199
|
|
|
179
200
|
itReturns(subject, {});
|
|
@@ -189,7 +210,7 @@ describe('[startup] Utils', () => {
|
|
|
189
210
|
});
|
|
190
211
|
});
|
|
191
212
|
|
|
192
|
-
describe(
|
|
213
|
+
describe(getStylelintConfiguration.name, () => {
|
|
193
214
|
const subject = () => getStylelintConfiguration();
|
|
194
215
|
|
|
195
216
|
itReturns(subject, {});
|
|
@@ -205,7 +226,23 @@ describe('[startup] Utils', () => {
|
|
|
205
226
|
});
|
|
206
227
|
});
|
|
207
228
|
|
|
208
|
-
describe(
|
|
229
|
+
describe(getVitestConfiguration.name, () => {
|
|
230
|
+
const subject = () => getVitestConfiguration();
|
|
231
|
+
|
|
232
|
+
itReturns(subject, {});
|
|
233
|
+
|
|
234
|
+
describe('with "cli.vitest"', () => {
|
|
235
|
+
const content = { cli: { vitest: { foo: 'bar' } } };
|
|
236
|
+
|
|
237
|
+
beforeEach(() => mockPackageJson(content));
|
|
238
|
+
|
|
239
|
+
test('return "cli.vitest"', () => {
|
|
240
|
+
expect(subject()).toEqual(content.cli.vitest);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe(getWebComponentConfiguration.name, () => {
|
|
209
246
|
let locationOrJson: string | Record<string, any> | undefined;
|
|
210
247
|
|
|
211
248
|
beforeEach(() => (locationOrJson = undefined));
|
|
@@ -317,7 +354,7 @@ describe('[startup] Utils', () => {
|
|
|
317
354
|
});
|
|
318
355
|
});
|
|
319
356
|
|
|
320
|
-
describe(
|
|
357
|
+
describe(getWebComponentBranchConfigs.name, () => {
|
|
321
358
|
const subject = () => getWebComponentBranchConfigs();
|
|
322
359
|
|
|
323
360
|
itReturns(subject, undefined);
|
|
@@ -333,7 +370,7 @@ describe('[startup] Utils', () => {
|
|
|
333
370
|
});
|
|
334
371
|
});
|
|
335
372
|
|
|
336
|
-
describe(
|
|
373
|
+
describe(hasHeadlessBundle.name, () => {
|
|
337
374
|
const subject = () => hasHeadlessBundle();
|
|
338
375
|
|
|
339
376
|
itReturns(subject, false);
|
|
@@ -410,7 +447,7 @@ describe('[startup] Utils', () => {
|
|
|
410
447
|
});
|
|
411
448
|
});
|
|
412
449
|
|
|
413
|
-
describe(
|
|
450
|
+
describe(isLegacy.name, () => {
|
|
414
451
|
const trigger = { cli: { legacy: true } };
|
|
415
452
|
let location: string | undefined;
|
|
416
453
|
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { getJestConfiguration } from '../get-configuration';
|
|
4
4
|
import { getDestinationFolders } from '../get-destination-folders';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { getJestConfigCLI } from '../get-jest-config';
|
|
7
7
|
|
|
8
8
|
jest.mock('../get-destination-folders');
|
|
9
9
|
jest.mock('../get-configuration', () => ({
|
|
@@ -14,20 +14,21 @@ jest.mock('../get-configuration', () => ({
|
|
|
14
14
|
describe('[startup] Utils', () => {
|
|
15
15
|
const destinationFolders = ['dist'];
|
|
16
16
|
const defaultConfig: Record<string, any> = {
|
|
17
|
-
|
|
18
|
-
testEnvironment: 'jsdom',
|
|
19
|
-
testRunner: 'jest-circus/runner',
|
|
20
|
-
transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],
|
|
21
|
-
modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],
|
|
22
|
-
moduleNameMapper: {
|
|
23
|
-
'\\.(css|scss|less|png|svg|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$': 'identity-obj-proxy',
|
|
24
|
-
},
|
|
25
|
-
testPathIgnorePatterns: ['\\.yalc', ...destinationFolders],
|
|
26
|
-
setupFiles: [expect.stringContaining(path.join('jest', 'setup.js'))],
|
|
17
|
+
collectCoverageFrom: ['**/*.{ts,tsx}'],
|
|
27
18
|
coveragePathIgnorePatterns: ['^.+\\.d\\.ts$'],
|
|
28
19
|
coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],
|
|
29
|
-
|
|
20
|
+
moduleNameMapper: {
|
|
21
|
+
'\\.(css|scss|less|png|svg|svg\\?\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':
|
|
22
|
+
'identity-obj-proxy',
|
|
23
|
+
},
|
|
24
|
+
modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],
|
|
30
25
|
preset: expect.stringMatching(/startup[\\\/]+jest/),
|
|
26
|
+
setupFiles: [expect.stringContaining(path.join('jest', 'setup.js'))],
|
|
27
|
+
testEnvironment: 'jsdom',
|
|
28
|
+
testPathIgnorePatterns: ['\\.yalc', ...destinationFolders],
|
|
29
|
+
testRunner: 'jest-circus/runner',
|
|
30
|
+
transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],
|
|
31
|
+
verbose: true,
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
beforeEach(() => {
|
|
@@ -35,62 +36,15 @@ describe('[startup] Utils', () => {
|
|
|
35
36
|
jest.mocked(getJestConfiguration).mockReturnValue({});
|
|
36
37
|
});
|
|
37
38
|
|
|
38
|
-
describe(`${getJestConfig.name}`, () => {
|
|
39
|
-
const subject = () => getJestConfig();
|
|
40
|
-
|
|
41
|
-
test('returns default config', () => {
|
|
42
|
-
expect(subject()).toEqual(defaultConfig);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe.each(['coveragePathIgnorePatterns', 'setupFiles', 'testPathIgnorePatterns'])(
|
|
46
|
-
'with custom "%s"',
|
|
47
|
-
(
|
|
48
|
-
option: keyof Pick<
|
|
49
|
-
typeof defaultConfig,
|
|
50
|
-
'coveragePathIgnorePatterns' | 'setupFiles' | 'testPathIgnorePatterns'
|
|
51
|
-
>
|
|
52
|
-
) => {
|
|
53
|
-
const customValue = ['foo', 'bar'];
|
|
54
|
-
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
jest.mocked(getJestConfiguration).mockReturnValue({ [option]: customValue });
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test(`appends custom value to "${option}"`, () => {
|
|
60
|
-
expect(subject()).toEqual(
|
|
61
|
-
expect.objectContaining({
|
|
62
|
-
[option]: [...defaultConfig[option], ...customValue],
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
describe('with other custom options', () => {
|
|
70
|
-
const customOptions = { resetMocks: true, testEnvironment: 'node' };
|
|
71
|
-
|
|
72
|
-
beforeEach(() => jest.mocked(getJestConfiguration).mockReturnValue(customOptions));
|
|
73
|
-
|
|
74
|
-
test('merges custom options with default config', () => {
|
|
75
|
-
expect(subject()).toEqual({ ...defaultConfig, ...customOptions });
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
39
|
describe(`${getJestConfigCLI.name}`, () => {
|
|
81
40
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
82
41
|
const args: Config.Argv = { _: [], $0: '', runInBand: true };
|
|
83
|
-
const globals = { foo: 'bar' };
|
|
84
42
|
|
|
85
43
|
const subject = () => getJestConfigCLI(args);
|
|
86
44
|
|
|
87
|
-
|
|
88
|
-
jest.mocked(getJestConfiguration).mockReturnValue({ globals });
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const stringified = ['collectCoverageFrom', 'moduleNameMapper', 'transform'].reduce(
|
|
45
|
+
const stringified = ['collectCoverageFrom', 'moduleNameMapper'].reduce(
|
|
92
46
|
(result, key) => ({ ...result, [key]: JSON.stringify(defaultConfig[key]) }),
|
|
93
|
-
{
|
|
47
|
+
{}
|
|
94
48
|
);
|
|
95
49
|
|
|
96
50
|
test(`merges command line args with default config and stringifies "${Object.keys(
|
|
@@ -102,5 +56,25 @@ describe('[startup] Utils', () => {
|
|
|
102
56
|
...stringified,
|
|
103
57
|
});
|
|
104
58
|
});
|
|
59
|
+
|
|
60
|
+
test('stringifies globals config', () => {
|
|
61
|
+
const globals = { foo: 'bar' };
|
|
62
|
+
|
|
63
|
+
jest.mocked(getJestConfiguration).mockReturnValue({ globals });
|
|
64
|
+
|
|
65
|
+
expect(subject()).toEqual(
|
|
66
|
+
expect.objectContaining({ globals: JSON.stringify(globals) })
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('stringifies transform config', () => {
|
|
71
|
+
const transform = { '\\.css$': 'some-css-transformer' };
|
|
72
|
+
|
|
73
|
+
jest.mocked(getJestConfiguration).mockReturnValue({ transform });
|
|
74
|
+
|
|
75
|
+
expect(subject()).toEqual(
|
|
76
|
+
expect.objectContaining({ transform: JSON.stringify(transform) })
|
|
77
|
+
);
|
|
78
|
+
});
|
|
105
79
|
});
|
|
106
80
|
});
|
|
@@ -4,6 +4,7 @@ import { ESLint } from 'eslint';
|
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { LinterOptions } from 'stylelint';
|
|
7
|
+
import { ViteUserConfig } from 'vitest/config';
|
|
7
8
|
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
|
|
8
9
|
|
|
9
10
|
import { ReviewConfiguration } from '../cli/commands/review';
|
|
@@ -81,6 +82,8 @@ export enum CommandName {
|
|
|
81
82
|
}
|
|
82
83
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
83
84
|
|
|
85
|
+
export type VitestConfiguration = ViteUserConfig['test'];
|
|
86
|
+
|
|
84
87
|
export interface WebComponentBranchConfigs {
|
|
85
88
|
publishTag?: string;
|
|
86
89
|
uploadSourcemaps?: boolean;
|
|
@@ -96,15 +99,18 @@ interface WebComponentOptions {
|
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
type Configuration = {
|
|
102
|
+
'jest'?: JestConfiguration;
|
|
99
103
|
'legacy'?: boolean;
|
|
100
104
|
'lint'?: { eslint: ESLintConfiguration; stylelint: StylelintConfiguration };
|
|
101
105
|
'review'?: ReviewConfiguration;
|
|
102
106
|
'swc-compile-package'?: Parameters<typeof swcDir>[0];
|
|
103
|
-
'test'?: JestConfiguration;
|
|
107
|
+
'test'?: JestConfiguration; // for backward-compatibility
|
|
108
|
+
'testRunner'?: string;
|
|
109
|
+
'vitest'?: VitestConfiguration;
|
|
104
110
|
'web-component'?: boolean | string | WebComponentOptions;
|
|
105
111
|
'webpack'?: false | WebpackConfiguration;
|
|
106
112
|
} & {
|
|
107
|
-
[key in CommandName]
|
|
113
|
+
[key in CommandName]?: NodeConfiguration;
|
|
108
114
|
} & NodeConfiguration;
|
|
109
115
|
|
|
110
116
|
type LocationOrJson = string | Record<string, any>;
|
|
@@ -130,7 +136,8 @@ export function getESLintConfiguration() {
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
export function getJestConfiguration() {
|
|
133
|
-
|
|
139
|
+
const configuration = getConfiguration();
|
|
140
|
+
return configuration.jest ?? configuration.test ?? {};
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
export function getReviewConfiguration() {
|
|
@@ -141,6 +148,10 @@ export function getStylelintConfiguration() {
|
|
|
141
148
|
return getConfiguration().lint?.stylelint ?? {};
|
|
142
149
|
}
|
|
143
150
|
|
|
151
|
+
export function getVitestConfiguration() {
|
|
152
|
+
return getConfiguration().vitest ?? {};
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
export function getWebpackConfiguration(locationOrJson?: LocationOrJson) {
|
|
145
156
|
const { webpack } = getConfiguration(locationOrJson);
|
|
146
157
|
return typeof webpack === 'object' ? webpack : {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
1
|
import { Config } from '@jest/types';
|
|
3
|
-
import
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { getJestConfiguration } from './get-configuration';
|
|
4
4
|
import { getDestinationFolders } from './get-destination-folders';
|
|
5
5
|
import { toArray } from './to-array';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function getDefaultJestConfiguration({
|
|
8
8
|
coveragePathIgnorePatterns = [],
|
|
9
9
|
setupFiles = [],
|
|
10
10
|
testPathIgnorePatterns = [],
|
|
@@ -12,68 +12,60 @@ const getJestConfigBase = ({
|
|
|
12
12
|
coveragePathIgnorePatterns?: string[];
|
|
13
13
|
setupFiles?: string[];
|
|
14
14
|
testPathIgnorePatterns?: string[];
|
|
15
|
-
})
|
|
15
|
+
}) {
|
|
16
16
|
const moduleNameMapper = {
|
|
17
|
-
'\\.(css|scss|less|png|svg|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':
|
|
17
|
+
'\\.(css|scss|less|png|svg|svg\\?\\w+|jpg|jpeg|gif|woff|woff2|eot|ttf|otf)$':
|
|
18
|
+
'identity-obj-proxy',
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],
|
|
25
|
-
modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],
|
|
22
|
+
collectCoverageFrom: ['**/*.{ts,tsx}'],
|
|
23
|
+
coveragePathIgnorePatterns: ['^.+\\.d\\.ts$', ...coveragePathIgnorePatterns],
|
|
24
|
+
coverageReporters: ['html-spa', 'text', 'json', 'cobertura', 'lcov'],
|
|
26
25
|
moduleNameMapper,
|
|
26
|
+
modulePathIgnorePatterns: ['<rootDir>/.*/__mocks__'],
|
|
27
|
+
preset: path.join(__dirname, '../../jest'),
|
|
28
|
+
setupFiles: [path.join(__dirname, '../../jest/setup.js'), ...toArray(setupFiles)],
|
|
29
|
+
testEnvironment: 'jsdom',
|
|
27
30
|
testPathIgnorePatterns: [
|
|
28
31
|
'\\.yalc',
|
|
29
32
|
...getDestinationFolders(),
|
|
30
33
|
...toArray(testPathIgnorePatterns),
|
|
31
34
|
],
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
collectCoverageFrom: ['**/*.{ts,tsx}'],
|
|
36
|
-
preset: path.join(__dirname, '../../jest'),
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get Jest clean config for running tests. This config could be used to export Jest configuration into the
|
|
42
|
-
* Jest config files.
|
|
43
|
-
*/
|
|
44
|
-
export const getJestConfig = (): JestConfiguration => {
|
|
45
|
-
const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } =
|
|
46
|
-
getJestConfiguration() as Record<string, any>;
|
|
47
|
-
return {
|
|
48
|
-
...getJestConfigBase({
|
|
49
|
-
coveragePathIgnorePatterns,
|
|
50
|
-
setupFiles,
|
|
51
|
-
testPathIgnorePatterns,
|
|
52
|
-
}),
|
|
53
|
-
...config,
|
|
35
|
+
testRunner: 'jest-circus/runner',
|
|
36
|
+
transformIgnorePatterns: ['node_modules/(?!(@servicetitan|@react-hook|nanoid|axios)/)'],
|
|
37
|
+
verbose: true,
|
|
54
38
|
};
|
|
55
|
-
}
|
|
39
|
+
}
|
|
56
40
|
|
|
57
41
|
/**
|
|
58
42
|
* Get Jest config for running it using jest CLI (see jest runCLI function)
|
|
59
43
|
*/
|
|
60
|
-
export
|
|
61
|
-
const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns,
|
|
44
|
+
export function getJestConfigCLI(args: Config.Argv): Config.Argv {
|
|
45
|
+
const { coveragePathIgnorePatterns, setupFiles, testPathIgnorePatterns, ...config } = {
|
|
62
46
|
...getJestConfiguration(),
|
|
63
47
|
...args,
|
|
64
48
|
};
|
|
65
49
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
50
|
+
return stringifyForCLI({
|
|
51
|
+
...getDefaultJestConfiguration({
|
|
52
|
+
coveragePathIgnorePatterns,
|
|
53
|
+
setupFiles,
|
|
54
|
+
testPathIgnorePatterns,
|
|
55
|
+
}),
|
|
56
|
+
...config,
|
|
70
57
|
});
|
|
58
|
+
}
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
function stringifyForCLI(config: any): Config.Argv {
|
|
61
|
+
return ['collectCoverageFrom', 'globals', 'moduleNameMapper', 'transform'].reduce(
|
|
62
|
+
(result, key) => {
|
|
63
|
+
const value = result[key];
|
|
64
|
+
if (value && typeof value !== 'string') {
|
|
65
|
+
result[key] = JSON.stringify(result[key]);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
config
|
|
70
|
+
);
|
|
71
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -34,8 +34,8 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
34
34
|
);
|
|
35
35
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
36
36
|
jest.mock('webpack', () => ({
|
|
37
|
-
...jest.requireActual('webpack'),
|
|
38
37
|
DefinePlugin: jest.fn(),
|
|
38
|
+
IgnorePlugin: jest.fn(),
|
|
39
39
|
}));
|
|
40
40
|
jest.mock('webpack-assets-manifest', () => ({ WebpackAssetsManifest: jest.fn() }));
|
|
41
41
|
jest.mock('webpack-remove-empty-scripts', () => jest.fn());
|
|
@@ -28,8 +28,8 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
28
28
|
);
|
|
29
29
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
30
30
|
jest.mock('webpack', () => ({
|
|
31
|
-
...jest.requireActual('webpack'),
|
|
32
31
|
DefinePlugin: jest.fn(),
|
|
32
|
+
IgnorePlugin: jest.fn(),
|
|
33
33
|
}));
|
|
34
34
|
jest.mock('webpack-assets-manifest', () => ({ WebpackAssetsManifest: jest.fn() }));
|
|
35
35
|
jest.mock('webpack-virtual-modules', () => jest.fn());
|
|
@@ -42,7 +42,7 @@ jest.mock('mini-css-extract-plugin', () =>
|
|
|
42
42
|
jest.mock('moment-locales-webpack-plugin', () => jest.fn());
|
|
43
43
|
jest.mock('terser-webpack-plugin', () => jest.fn());
|
|
44
44
|
jest.mock('webpack', () => ({
|
|
45
|
-
|
|
45
|
+
DefinePlugin: jest.fn(),
|
|
46
46
|
IgnorePlugin: jest.fn(),
|
|
47
47
|
ProvidePlugin: jest.fn(),
|
|
48
48
|
}));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Config } from '@jest/types';
|
|
2
|
-
import { Command } from '.';
|
|
3
|
-
/**
|
|
4
|
-
* Named as tests to exclude it from the Jest pattern
|
|
5
|
-
*/
|
|
6
|
-
export declare class Tests implements Command {
|
|
7
|
-
private args;
|
|
8
|
-
readonly greedy = true;
|
|
9
|
-
constructor(args: Config.Argv);
|
|
10
|
-
description(): string;
|
|
11
|
-
execute(): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=tests.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tests.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAE5B;;GAEG;AACH,qBAAa,KAAM,YAAW,OAAO;IAGrB,OAAO,CAAC,IAAI;IAFxB,QAAQ,CAAC,MAAM,QAAQ;gBAEH,IAAI,EAAE,MAAM,CAAC,IAAI;IAErC,WAAW;IAKL,OAAO;CAWhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/commands/tests.ts"],"sourcesContent":["import { Config } from '@jest/types';\nimport { runCLI } from '@jest/core';\nimport { getJestConfigCLI, logErrors } from '../../utils';\nimport { Command } from '.';\n\n/**\n * Named as tests to exclude it from the Jest pattern\n */\nexport class Tests implements Command {\n readonly greedy = true;\n\n constructor(private args: Config.Argv) {}\n\n description() {\n return 'run tests';\n }\n\n @logErrors\n async execute() {\n const jestConfig = getJestConfigCLI(this.args);\n const {\n results: { success },\n } = await runCLI(jestConfig, [process.cwd()]);\n\n if (!success) {\n // eslint-disable-next-line require-atomic-updates\n process.exitCode = 1;\n }\n }\n}\n"],"names":["Tests","description","execute","jestConfig","getJestConfigCLI","args","results","success","runCLI","process","cwd","exitCode","greedy"],"mappings":";;;;+BAQaA;;;eAAAA;;;sBAPU;uBACqB;;;;;;;;;;;;;;;;;;;;;;;AAMrC,MAAMA;IAKTC,cAAc;QACV,OAAO;IACX;IAEA,MACMC,UAAU;QACZ,MAAMC,aAAaC,IAAAA,uBAAgB,EAAC,IAAI,CAACC,IAAI;QAC7C,MAAM,EACFC,SAAS,EAAEC,OAAO,EAAE,EACvB,GAAG,MAAMC,IAAAA,YAAM,EAACL,YAAY;YAACM,QAAQC,GAAG;SAAG;QAE5C,IAAI,CAACH,SAAS;YACV,kDAAkD;YAClDE,QAAQE,QAAQ,GAAG;QACvB;IACJ;IAjBA,YAAY,AAAQN,IAAiB,CAAE;;QAFvC,uBAASO,UAAT,KAAA;aAEoBP,OAAAA;aAFXO,SAAS;IAEsB;AAkB5C"}
|
package/dist/jest/index.d.ts
DELETED
package/dist/jest/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/jest/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,yCAE/B"}
|
package/dist/jest/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createJestConfig", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createJestConfig;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _utils = require("../utils");
|
|
12
|
-
function createJestConfig() {
|
|
13
|
-
return (0, _utils.getJestConfig)();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
package/dist/jest/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/jest/index.ts"],"sourcesContent":["import { getJestConfig } from '../utils';\n\nexport function createJestConfig() {\n return getJestConfig();\n}\n"],"names":["createJestConfig","getJestConfig"],"mappings":";;;;+BAEgBA;;;eAAAA;;;uBAFc;AAEvB,SAASA;IACZ,OAAOC,IAAAA,oBAAa;AACxB"}
|