Skip to content

Commit 40b769b

Browse files
authored
test: run unit tests and e2e tests in 1 single command yarn test (#1180)
1 parent 2a22998 commit 40b769b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+550
-562
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ jobs:
7373
cache: yarn
7474
- name: Install and build
7575
run: yarn --immutable
76-
- name: Run unit tests
77-
run: yarn test-unit
78-
- name: Run e2e tests
79-
run: yarn test-e2e
76+
- name: Run tests
77+
run: yarn test
8078
- name: Run tests in example projects
8179
run: yarn test-examples
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
import { jsonNoCache as runWithJsonNoCache } from '../run-jest';
22

3-
describe('hoisting', () => {
4-
const DIR = 'ast-transformers/hoisting';
5-
6-
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
7-
const { json } = runWithJsonNoCache(DIR);
3+
const executeTest = (dirName: string): void => {
4+
test(`successfully runs the tests inside ${dirName} with isolatedModules: false`, () => {
5+
const { json } = runWithJsonNoCache(dirName);
86

97
expect(json.success).toBe(true);
108
});
119

12-
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
13-
const { json } = runWithJsonNoCache(DIR, ['-c=jest-isolated.config.js']);
10+
test(`successfully runs the tests inside ${dirName} with isolatedModules: true`, () => {
11+
const { json } = runWithJsonNoCache(dirName, ['-c=jest-isolated.config.js']);
1412

1513
expect(json.success).toBe(true);
1614
});
15+
};
16+
17+
describe('hoisting', () => {
18+
executeTest('ast-transformers/hoisting');
1719
});
1820

1921
describe('ng-jit-transformers', () => {
20-
const DIR = 'ast-transformers/ng-jit-transformers';
21-
22-
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
23-
const { json } = runWithJsonNoCache(DIR);
24-
25-
expect(json.success).toBe(true);
26-
});
27-
28-
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
29-
const { json } = runWithJsonNoCache(DIR, ['-c=jest-isolated.config.js']);
30-
31-
expect(json.success).toBe(true);
32-
});
22+
executeTest('ast-transformers/ng-jit-transformers');
3323
});

e2e/__tests__/async.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import path from 'path';
33
import { jsonNoCache as runWithJsonNoCache } from '../run-jest';
44
import { runYarnInstall } from '../utils';
55

6-
const DIR = path.join(__dirname, '..', 'async');
6+
const DIR = 'async';
77

88
beforeAll(() => {
9-
runYarnInstall(DIR);
9+
runYarnInstall(path.join(__dirname, '..', DIR));
1010
});
1111

12-
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
12+
test(`successfully run the tests inside ${DIR} with isolatedModules: false`, () => {
1313
const { json } = runWithJsonNoCache(DIR);
1414

1515
expect(json.success).toBe(true);
1616
});
1717

18-
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
18+
test(`successfully run the tests inside ${DIR} with isolatedModules: true`, () => {
1919
const { json } = runWithJsonNoCache(DIR, ['-c=jest-isolated.config.js']);
2020

2121
expect(json.success).toBe(true);

e2e/__tests__/babel-support.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import path from 'path';
33
import { jsonNoCache as runWithJsonNoCache } from '../run-jest';
44
import { runYarnInstall } from '../utils';
55

6-
const DIR = path.join(__dirname, '..', 'babel-support');
6+
const DIR = 'babel-support';
77

88
beforeAll(() => {
9-
runYarnInstall(DIR);
9+
runYarnInstall(path.join(__dirname, '..', DIR));
1010
});
1111

12-
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
12+
test(`successfully run the tests inside ${DIR} with isolatedModules: false`, () => {
1313
const { json } = runWithJsonNoCache(DIR);
1414

1515
expect(json.success).toBe(true);
1616
});
1717

18-
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
18+
test(`successfully run the tests inside ${DIR} with isolatedModules: true`, () => {
1919
const { json } = runWithJsonNoCache(DIR, ['-c=jest-isolated.config.js']);
2020

2121
expect(json.success).toBe(true);

e2e/__tests__/custom-typings.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ import path from 'path';
33
import { jsonNoCache as runWithJsonNoCache } from '../run-jest';
44
import { runYarnInstall } from '../utils';
55

6-
const DIR = path.join(__dirname, '..', 'custom-typings');
6+
const DIR = 'custom-typings';
77

88
beforeAll(() => {
9-
runYarnInstall(DIR);
9+
runYarnInstall(path.join(__dirname, '..', DIR));
1010
});
1111

12-
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
12+
test(`successfully run the tests inside ${DIR} with isolatedModules: false`, () => {
1313
const { json } = runWithJsonNoCache(DIR);
1414

1515
expect(json.success).toBe(true);
1616
});
1717

18-
test(`successfully runs the tests inside ${DIR} with isolatedModules: true`, () => {
18+
test(`successfully run the tests inside ${DIR} with isolatedModules: true`, () => {
1919
const { json } = runWithJsonNoCache(DIR, ['-c=jest-isolated.config.js']);
2020

2121
expect(json.success).toBe(true);

e2e/__tests__/jest-globals.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
import path from 'path';
2+
13
import { jsonNoCache as runWithJsonNoCache } from '../run-jest';
4+
import { runYarnInstall } from '../utils';
25

36
const DIR = 'jest-globals';
47

8+
beforeAll(() => {
9+
runYarnInstall(path.join(__dirname, '..', DIR));
10+
});
11+
512
test(`successfully runs the tests inside ${DIR} with isolatedModules: false`, () => {
613
const { json } = runWithJsonNoCache(DIR);
714

0 commit comments

Comments
 (0)