-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
TypeScriptGenerateTrace.spec.ts
92 lines (78 loc) · 3.36 KB
/
TypeScriptGenerateTrace.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { readFixture } from './sandbox/Fixture';
import { join } from 'path';
import { createSandbox, Sandbox } from './sandbox/Sandbox';
import {
createWebpackDevServerDriver,
WEBPACK_CLI_VERSION,
WEBPACK_DEV_SERVER_VERSION,
} from './sandbox/WebpackDevServerDriver';
import { FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION } from './sandbox/Plugin';
describe('TypeScript Generate Trace', () => {
let sandbox: Sandbox;
beforeAll(async () => {
sandbox = await createSandbox();
});
beforeEach(async () => {
await sandbox.reset();
});
afterAll(async () => {
await sandbox.cleanup();
});
it('generates trace for typescript 4.1.0-beta in watch mode', async () => {
await sandbox.load([
await readFixture(join(__dirname, 'fixtures/environment/typescript-basic.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify('^7.0.0'),
TYPESCRIPT_VERSION: JSON.stringify('4.1.0-beta'),
WEBPACK_VERSION: JSON.stringify('^4.0.0'),
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
ASYNC: JSON.stringify(true),
}),
await readFixture(join(__dirname, 'fixtures/implementation/typescript-basic.fixture')),
]);
// update sandbox to generate trace
await sandbox.patch(
'tsconfig.json',
' "outDir": "./dist"',
[' "outDir": "./dist",', ' "generateTrace": "./traces"'].join('\n')
);
const driver = createWebpackDevServerDriver(sandbox.spawn('npm run webpack-dev-server'), true);
// first compilation is successful
await driver.waitForNoErrors();
expect(await sandbox.exists('traces/trace.json')).toBe(true);
expect(await sandbox.exists('traces/types.json')).toBe(true);
});
it('generates trace for typescript 4.1.0-beta in build mode', async () => {
await sandbox.load([
await readFixture(join(__dirname, 'fixtures/environment/typescript-monorepo.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TYPESCRIPT_VERSION: JSON.stringify('4.1.0-beta'),
WEBPACK_VERSION: JSON.stringify('^4.0.0'),
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
ASYNC: JSON.stringify(true),
MODE: JSON.stringify('readonly'),
}),
await readFixture(join(__dirname, 'fixtures/implementation/typescript-monorepo.fixture')),
]);
// update sandbox to generate trace
await sandbox.patch(
'tsconfig.base.json',
' "rootDir": "./packages"',
[' "rootDir": "./packages",', ' "generateTrace": "./traces"'].join('\n')
);
const driver = createWebpackDevServerDriver(sandbox.spawn('npm run webpack-dev-server'), true);
// first compilation is successful
await driver.waitForNoErrors();
expect(await sandbox.exists('traces/trace.1.json')).toBe(true);
expect(await sandbox.exists('traces/types.1.json')).toBe(true);
expect(await sandbox.exists('traces/trace.2.json')).toBe(true);
expect(await sandbox.exists('traces/types.2.json')).toBe(true);
expect(await sandbox.exists('traces/legend.json')).toBe(true);
});
});