Skip to content

Commit 5f5baab

Browse files
committed
test: update tests for compatibility with windows
1 parent 9023cd2 commit 5f5baab

12 files changed

+101
-66
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"@commitlint/config-conventional": "^8.3.4",
7373
"@mdx-js/mdx": "^1.5.8",
7474
"@types/babel__code-frame": "^7.0.1",
75+
"@types/cross-spawn": "^6.0.2",
7576
"@types/eslint": "^6.8.0",
7677
"@types/fs-extra": "^8.1.0",
7778
"@types/jest": "^25.2.1",
@@ -85,6 +86,7 @@
8586
"@typescript-eslint/eslint-plugin": "^2.27.0",
8687
"@typescript-eslint/parser": "^2.27.0",
8788
"commitlint": "^8.3.5",
89+
"cross-spawn": "^7.0.2",
8890
"eslint": "^6.8.0",
8991
"eslint-config-prettier": "^6.10.1",
9092
"eslint-plugin-node": "^11.1.0",
@@ -101,6 +103,7 @@
101103
"ts-jest": "^25.3.1",
102104
"ts-loader": "^6.2.2",
103105
"typescript": "^3.8.3",
106+
"unixify": "^1.0.0",
104107
"vue": "^2.6.11",
105108
"vue-class-component": "^7.2.3",
106109
"vue-loader": "^15.9.1",

test/e2e/EsLint.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,20 @@ describe('EsLint', () => {
3030
])('reports lint error for %p', async ({ async, webpack }) => {
3131
await sandbox.load(
3232
await readFixture(join(__dirname, 'fixtures/eslint-basic.fixture'), {
33-
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
34-
TS_LOADER_VERSION: '^5.0.0',
35-
TYPESCRIPT_VERSION: '~3.8.0',
36-
WEBPACK_VERSION: webpack,
37-
WEBPACK_CLI_VERSION,
38-
WEBPACK_DEV_SERVER_VERSION,
39-
ASYNC: async ? 'true' : 'false',
33+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
34+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
35+
),
36+
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
37+
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
38+
WEBPACK_VERSION: JSON.stringify(webpack),
39+
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
40+
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
41+
ASYNC: JSON.stringify(async),
4042
})
4143
);
4244

4345
const driver = createWebpackDevServerDriver(
44-
sandbox.spawn('yarn exec webpack-dev-server'),
46+
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
4547
async
4648
);
4749
let errors: string[];

test/e2e/PluginOutOfMemory.spec.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ describe('ForkTsCheckerWebpackPlugin Out Of Memory', () => {
2626
])('handles out of memory for %p', async ({ async, webpack }) => {
2727
await sandbox.load(
2828
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
29-
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
30-
TS_LOADER_VERSION: '^5.0.0',
31-
TYPESCRIPT_VERSION: '~3.8.0',
32-
WEBPACK_VERSION: webpack,
33-
WEBPACK_CLI_VERSION: '^3.3.11',
34-
WEBPACK_DEV_SERVER_VERSION: '^3.10.3',
35-
ASYNC: async ? 'true' : 'false',
29+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
30+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
31+
),
32+
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
33+
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
34+
WEBPACK_VERSION: JSON.stringify(webpack),
35+
WEBPACK_CLI_VERSION: JSON.stringify('^3.3.11'),
36+
WEBPACK_DEV_SERVER_VERSION: JSON.stringify('^3.10.3'),
37+
ASYNC: JSON.stringify(async),
3638
})
3739
);
3840

@@ -48,7 +50,9 @@ describe('ForkTsCheckerWebpackPlugin Out Of Memory', () => {
4850
].join('\n')
4951
);
5052

51-
const driver = createGenericProcessDriver(sandbox.spawn('yarn exec webpack-dev-server'));
53+
const driver = createGenericProcessDriver(
54+
sandbox.spawn('./node_modules/.bin/webpack-dev-server')
55+
);
5256

5357
// we should see an error message about out of memory
5458
await driver.waitForStderrIncludes(

test/e2e/TypeScriptSolutionBuilderApi.spec.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ describe('TypeScript SolutionBuilder API', () => {
2828
async ({ async }) => {
2929
await sandbox.load(
3030
await readFixture(join(__dirname, 'fixtures/typescript-project-references.fixture'), {
31-
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
32-
TS_LOADER_VERSION: '^7.0.1',
33-
TYPESCRIPT_VERSION: '~3.8.0',
34-
WEBPACK_VERSION: '^4.0.0',
35-
WEBPACK_CLI_VERSION,
36-
WEBPACK_DEV_SERVER_VERSION,
37-
ASYNC: async ? 'true' : 'false',
31+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
32+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
33+
),
34+
TS_LOADER_VERSION: JSON.stringify('^7.0.1'),
35+
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
36+
WEBPACK_VERSION: JSON.stringify('^4.0.0'),
37+
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
38+
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
39+
ASYNC: JSON.stringify(async),
3840
})
3941
);
4042

4143
const driver = createWebpackDevServerDriver(
42-
sandbox.spawn('yarn exec webpack-dev-server'),
44+
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
4345
async
4446
);
4547
let errors: string[];

test/e2e/TypeScriptWatchApi.spec.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ describe('TypeScript Watch API', () => {
3333
async ({ async, webpack }) => {
3434
await sandbox.load(
3535
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
36-
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
37-
TS_LOADER_VERSION: '^5.0.0',
38-
TYPESCRIPT_VERSION: '~3.8.0',
39-
WEBPACK_VERSION: webpack,
40-
WEBPACK_CLI_VERSION,
41-
WEBPACK_DEV_SERVER_VERSION,
42-
ASYNC: async ? 'true' : 'false',
36+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
37+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
38+
),
39+
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
40+
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
41+
WEBPACK_VERSION: JSON.stringify(webpack),
42+
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
43+
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
44+
ASYNC: JSON.stringify(async),
4345
})
4446
);
4547

@@ -52,7 +54,7 @@ describe('TypeScript Watch API', () => {
5254
);
5355

5456
const driver = createWebpackDevServerDriver(
55-
sandbox.spawn('yarn exec webpack-dev-server'),
57+
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
5658
async
5759
);
5860
let errors: string[];
@@ -155,18 +157,20 @@ describe('TypeScript Watch API', () => {
155157
])('reports semantic error for %p', async ({ async, webpack, typescript, tsloader }) => {
156158
await sandbox.load(
157159
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
158-
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
159-
TS_LOADER_VERSION: tsloader,
160-
TYPESCRIPT_VERSION: typescript,
161-
WEBPACK_VERSION: webpack,
162-
WEBPACK_CLI_VERSION,
163-
WEBPACK_DEV_SERVER_VERSION,
164-
ASYNC: async ? 'true' : 'false',
160+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
161+
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
162+
),
163+
TS_LOADER_VERSION: JSON.stringify(tsloader),
164+
TYPESCRIPT_VERSION: JSON.stringify(typescript),
165+
WEBPACK_VERSION: JSON.stringify(webpack),
166+
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
167+
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
168+
ASYNC: JSON.stringify(async),
165169
})
166170
);
167171

168172
const driver = createWebpackDevServerDriver(
169-
sandbox.spawn('yarn exec webpack-dev-server'),
173+
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
170174
async
171175
);
172176
let errors: string[];

test/e2e/fixtures/eslint-basic.fixture

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"@typescript-eslint/eslint-plugin": "^2.27.0",
1010
"@typescript-eslint/parser": "^2.27.0",
1111
"eslint": "^6.8.0",
12-
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
13-
"ts-loader": "${TS_LOADER_VERSION}",
14-
"typescript": "${TYPESCRIPT_VERSION}",
15-
"webpack": "${WEBPACK_VERSION}",
16-
"webpack-cli": "${WEBPACK_CLI_VERSION}",
17-
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
12+
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
13+
"ts-loader": ${TS_LOADER_VERSION},
14+
"typescript": ${TYPESCRIPT_VERSION},
15+
"webpack": ${WEBPACK_VERSION},
16+
"webpack-cli": ${WEBPACK_CLI_VERSION},
17+
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
1818
}
1919
}
2020
/// tsconfig.json

test/e2e/fixtures/typescript-basic.fixture

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"main": "dist/index.js",
66
"license": "MIT",
77
"devDependencies": {
8-
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
9-
"ts-loader": "${TS_LOADER_VERSION}",
10-
"typescript": "${TYPESCRIPT_VERSION}",
11-
"webpack": "${WEBPACK_VERSION}",
12-
"webpack-cli": "${WEBPACK_CLI_VERSION}",
13-
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
8+
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
9+
"ts-loader": ${TS_LOADER_VERSION},
10+
"typescript": ${TYPESCRIPT_VERSION},
11+
"webpack": ${WEBPACK_VERSION},
12+
"webpack-cli": ${WEBPACK_CLI_VERSION},
13+
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
1414
}
1515
}
1616
/// tsconfig.json

test/e2e/fixtures/typescript-project-references.fixture

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
"packages/*"
99
],
1010
"devDependencies": {
11-
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
12-
"ts-loader": "${TS_LOADER_VERSION}",
13-
"typescript": "${TYPESCRIPT_VERSION}",
14-
"webpack": "${WEBPACK_VERSION}",
15-
"webpack-cli": "${WEBPACK_CLI_VERSION}",
16-
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
11+
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
12+
"ts-loader": ${TS_LOADER_VERSION},
13+
"typescript": ${TYPESCRIPT_VERSION},
14+
"webpack": ${WEBPACK_VERSION},
15+
"webpack-cli": ${WEBPACK_CLI_VERSION},
16+
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
1717
}
1818
}
1919

test/e2e/sandbox/Sandbox.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { join, resolve, dirname } from 'path';
22
import fs from 'fs-extra';
33
import os from 'os';
44
import chalk from 'chalk';
5-
import { exec, spawn, ChildProcess } from 'child_process';
5+
import { exec, ChildProcess } from 'child_process';
6+
import spawn from 'cross-spawn';
67
import { Fixture } from './Fixture';
78
import stripAnsi from 'strip-ansi';
89

@@ -37,7 +38,9 @@ async function createSandbox(): Promise<Sandbox> {
3738
process.stdout.write(chalk.blue('Installing dependencies...\n'));
3839
// use custom directory to not use cached version of the plugin
3940
const YARN_CACHE_FOLDER = join(sandbox.context, '.yarn');
40-
await sandbox.exec('yarn install', {
41+
// use --ignore-optional to speedup the installation and to omit `fsevents` as
42+
// webpack 4 uses old version which sometimes behave non-deterministic
43+
await sandbox.exec('yarn install --ignore-optional', {
4144
YARN_CACHE_FOLDER,
4245
});
4346
process.stdout.write(chalk.green('The sandbox initialized successfully.\n'));
@@ -113,7 +116,7 @@ async function createSandbox(): Promise<Sandbox> {
113116
},
114117
patch: async (path: string, search: string, replacement: string) => {
115118
process.stdout.write(
116-
`Patching file ${path} - replacing ${search} with "${replacement}"...\n`
119+
`Patching file ${path} - replacing "${search}" with "${replacement}"...\n`
117120
);
118121
const realPath = join(context, path);
119122
const content = await fs.readFile(realPath, 'utf-8');

test/unit/formatter/WebpackFormatter.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os from 'os';
2-
import { join } from 'path';
2+
import { join, sep } from 'path';
33
import { Issue } from 'lib/issue';
44
import { createBasicFormatter, createWebpackFormatter, Formatter } from 'lib/formatter';
55

@@ -38,7 +38,7 @@ describe('formatter/WebpackFormatter', () => {
3838
});
3939

4040
it('formats issue file', () => {
41-
expect(formatter(issue)).toContain('some/file.ts');
41+
expect(formatter(issue)).toContain(`some${sep}file.ts`);
4242
});
4343

4444
it('formats location', () => {
@@ -53,7 +53,7 @@ describe('formatter/WebpackFormatter', () => {
5353

5454
it('formats issue header like webpack', () => {
5555
expect(formatter(issue)).toEqual(
56-
['ERROR in some/file.ts 1:7-16', 'TS123: Some issue content', ''].join(os.EOL)
56+
[`ERROR in some${sep}file.ts 1:7-16`, 'TS123: Some issue content', ''].join(os.EOL)
5757
);
5858
});
5959
});

0 commit comments

Comments
 (0)