Skip to content

Commit

Permalink
test: update tests for compatibility with windows
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-oles committed May 16, 2020
1 parent 9023cd2 commit 5f5baab
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 66 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"@commitlint/config-conventional": "^8.3.4",
"@mdx-js/mdx": "^1.5.8",
"@types/babel__code-frame": "^7.0.1",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^6.8.0",
"@types/fs-extra": "^8.1.0",
"@types/jest": "^25.2.1",
Expand All @@ -85,6 +86,7 @@
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"commitlint": "^8.3.5",
"cross-spawn": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-node": "^11.1.0",
Expand All @@ -101,6 +103,7 @@
"ts-jest": "^25.3.1",
"ts-loader": "^6.2.2",
"typescript": "^3.8.3",
"unixify": "^1.0.0",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-loader": "^15.9.1",
Expand Down
18 changes: 10 additions & 8 deletions test/e2e/EsLint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ describe('EsLint', () => {
])('reports lint error for %p', async ({ async, webpack }) => {
await sandbox.load(
await readFixture(join(__dirname, 'fixtures/eslint-basic.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
TS_LOADER_VERSION: '^5.0.0',
TYPESCRIPT_VERSION: '~3.8.0',
WEBPACK_VERSION: webpack,
WEBPACK_CLI_VERSION,
WEBPACK_DEV_SERVER_VERSION,
ASYNC: async ? 'true' : 'false',
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
WEBPACK_VERSION: JSON.stringify(webpack),
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
ASYNC: JSON.stringify(async),
})
);

const driver = createWebpackDevServerDriver(
sandbox.spawn('yarn exec webpack-dev-server'),
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
async
);
let errors: string[];
Expand Down
20 changes: 12 additions & 8 deletions test/e2e/PluginOutOfMemory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ describe('ForkTsCheckerWebpackPlugin Out Of Memory', () => {
])('handles out of memory for %p', async ({ async, webpack }) => {
await sandbox.load(
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
TS_LOADER_VERSION: '^5.0.0',
TYPESCRIPT_VERSION: '~3.8.0',
WEBPACK_VERSION: webpack,
WEBPACK_CLI_VERSION: '^3.3.11',
WEBPACK_DEV_SERVER_VERSION: '^3.10.3',
ASYNC: async ? 'true' : 'false',
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
WEBPACK_VERSION: JSON.stringify(webpack),
WEBPACK_CLI_VERSION: JSON.stringify('^3.3.11'),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify('^3.10.3'),
ASYNC: JSON.stringify(async),
})
);

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

const driver = createGenericProcessDriver(sandbox.spawn('yarn exec webpack-dev-server'));
const driver = createGenericProcessDriver(
sandbox.spawn('./node_modules/.bin/webpack-dev-server')
);

// we should see an error message about out of memory
await driver.waitForStderrIncludes(
Expand Down
18 changes: 10 additions & 8 deletions test/e2e/TypeScriptSolutionBuilderApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ describe('TypeScript SolutionBuilder API', () => {
async ({ async }) => {
await sandbox.load(
await readFixture(join(__dirname, 'fixtures/typescript-project-references.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
TS_LOADER_VERSION: '^7.0.1',
TYPESCRIPT_VERSION: '~3.8.0',
WEBPACK_VERSION: '^4.0.0',
WEBPACK_CLI_VERSION,
WEBPACK_DEV_SERVER_VERSION,
ASYNC: async ? 'true' : 'false',
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify('^7.0.1'),
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
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(async),
})
);

const driver = createWebpackDevServerDriver(
sandbox.spawn('yarn exec webpack-dev-server'),
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
async
);
let errors: string[];
Expand Down
36 changes: 20 additions & 16 deletions test/e2e/TypeScriptWatchApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ describe('TypeScript Watch API', () => {
async ({ async, webpack }) => {
await sandbox.load(
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
TS_LOADER_VERSION: '^5.0.0',
TYPESCRIPT_VERSION: '~3.8.0',
WEBPACK_VERSION: webpack,
WEBPACK_CLI_VERSION,
WEBPACK_DEV_SERVER_VERSION,
ASYNC: async ? 'true' : 'false',
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify('^5.0.0'),
TYPESCRIPT_VERSION: JSON.stringify('~3.8.0'),
WEBPACK_VERSION: JSON.stringify(webpack),
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
ASYNC: JSON.stringify(async),
})
);

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

const driver = createWebpackDevServerDriver(
sandbox.spawn('yarn exec webpack-dev-server'),
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
async
);
let errors: string[];
Expand Down Expand Up @@ -155,18 +157,20 @@ describe('TypeScript Watch API', () => {
])('reports semantic error for %p', async ({ async, webpack, typescript, tsloader }) => {
await sandbox.load(
await readFixture(join(__dirname, 'fixtures/typescript-basic.fixture'), {
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION,
TS_LOADER_VERSION: tsloader,
TYPESCRIPT_VERSION: typescript,
WEBPACK_VERSION: webpack,
WEBPACK_CLI_VERSION,
WEBPACK_DEV_SERVER_VERSION,
ASYNC: async ? 'true' : 'false',
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION: JSON.stringify(
FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION
),
TS_LOADER_VERSION: JSON.stringify(tsloader),
TYPESCRIPT_VERSION: JSON.stringify(typescript),
WEBPACK_VERSION: JSON.stringify(webpack),
WEBPACK_CLI_VERSION: JSON.stringify(WEBPACK_CLI_VERSION),
WEBPACK_DEV_SERVER_VERSION: JSON.stringify(WEBPACK_DEV_SERVER_VERSION),
ASYNC: JSON.stringify(async),
})
);

const driver = createWebpackDevServerDriver(
sandbox.spawn('yarn exec webpack-dev-server'),
sandbox.spawn('./node_modules/.bin/webpack-dev-server'),
async
);
let errors: string[];
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/fixtures/eslint-basic.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"eslint": "^6.8.0",
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
"ts-loader": "${TS_LOADER_VERSION}",
"typescript": "${TYPESCRIPT_VERSION}",
"webpack": "${WEBPACK_VERSION}",
"webpack-cli": "${WEBPACK_CLI_VERSION}",
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
"ts-loader": ${TS_LOADER_VERSION},
"typescript": ${TYPESCRIPT_VERSION},
"webpack": ${WEBPACK_VERSION},
"webpack-cli": ${WEBPACK_CLI_VERSION},
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
}
}
/// tsconfig.json
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/fixtures/typescript-basic.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"main": "dist/index.js",
"license": "MIT",
"devDependencies": {
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
"ts-loader": "${TS_LOADER_VERSION}",
"typescript": "${TYPESCRIPT_VERSION}",
"webpack": "${WEBPACK_VERSION}",
"webpack-cli": "${WEBPACK_CLI_VERSION}",
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
"ts-loader": ${TS_LOADER_VERSION},
"typescript": ${TYPESCRIPT_VERSION},
"webpack": ${WEBPACK_VERSION},
"webpack-cli": ${WEBPACK_CLI_VERSION},
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
}
}
/// tsconfig.json
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/fixtures/typescript-project-references.fixture
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"packages/*"
],
"devDependencies": {
"fork-ts-checker-webpack-plugin": "${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION}",
"ts-loader": "${TS_LOADER_VERSION}",
"typescript": "${TYPESCRIPT_VERSION}",
"webpack": "${WEBPACK_VERSION}",
"webpack-cli": "${WEBPACK_CLI_VERSION}",
"webpack-dev-server": "${WEBPACK_DEV_SERVER_VERSION}"
"fork-ts-checker-webpack-plugin": ${FORK_TS_CHECKER_WEBPACK_PLUGIN_VERSION},
"ts-loader": ${TS_LOADER_VERSION},
"typescript": ${TYPESCRIPT_VERSION},
"webpack": ${WEBPACK_VERSION},
"webpack-cli": ${WEBPACK_CLI_VERSION},
"webpack-dev-server": ${WEBPACK_DEV_SERVER_VERSION}
}
}

Expand Down
9 changes: 6 additions & 3 deletions test/e2e/sandbox/Sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { join, resolve, dirname } from 'path';
import fs from 'fs-extra';
import os from 'os';
import chalk from 'chalk';
import { exec, spawn, ChildProcess } from 'child_process';
import { exec, ChildProcess } from 'child_process';
import spawn from 'cross-spawn';
import { Fixture } from './Fixture';
import stripAnsi from 'strip-ansi';

Expand Down Expand Up @@ -37,7 +38,9 @@ async function createSandbox(): Promise<Sandbox> {
process.stdout.write(chalk.blue('Installing dependencies...\n'));
// use custom directory to not use cached version of the plugin
const YARN_CACHE_FOLDER = join(sandbox.context, '.yarn');
await sandbox.exec('yarn install', {
// use --ignore-optional to speedup the installation and to omit `fsevents` as
// webpack 4 uses old version which sometimes behave non-deterministic
await sandbox.exec('yarn install --ignore-optional', {
YARN_CACHE_FOLDER,
});
process.stdout.write(chalk.green('The sandbox initialized successfully.\n'));
Expand Down Expand Up @@ -113,7 +116,7 @@ async function createSandbox(): Promise<Sandbox> {
},
patch: async (path: string, search: string, replacement: string) => {
process.stdout.write(
`Patching file ${path} - replacing ${search} with "${replacement}"...\n`
`Patching file ${path} - replacing "${search}" with "${replacement}"...\n`
);
const realPath = join(context, path);
const content = await fs.readFile(realPath, 'utf-8');
Expand Down
6 changes: 3 additions & 3 deletions test/unit/formatter/WebpackFormatter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os from 'os';
import { join } from 'path';
import { join, sep } from 'path';
import { Issue } from 'lib/issue';
import { createBasicFormatter, createWebpackFormatter, Formatter } from 'lib/formatter';

Expand Down Expand Up @@ -38,7 +38,7 @@ describe('formatter/WebpackFormatter', () => {
});

it('formats issue file', () => {
expect(formatter(issue)).toContain('some/file.ts');
expect(formatter(issue)).toContain(`some${sep}file.ts`);
});

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

it('formats issue header like webpack', () => {
expect(formatter(issue)).toEqual(
['ERROR in some/file.ts 1:7-16', 'TS123: Some issue content', ''].join(os.EOL)
[`ERROR in some${sep}file.ts 1:7-16`, 'TS123: Some issue content', ''].join(os.EOL)
);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import webpack from 'webpack';
import unixify from 'unixify';
import { TypeScriptReporterConfiguration } from 'lib/typescript-reporter/TypeScriptReporterConfiguration';
import { TypeScriptReporterOptions } from 'lib/typescript-reporter/TypeScriptReporterOptions';

Expand Down Expand Up @@ -87,7 +88,9 @@ describe('typescript-reporter/TypeScriptsReporterConfiguration', () => {
options as TypeScriptReporterOptions
);

expect(configuration).toEqual(expectedConfiguration);
expect({ ...configuration, tsconfig: unixify(configuration.tsconfig) }).toEqual(
expectedConfiguration
);
});

it('passes vue options to the vue extension', async () => {
Expand Down
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,13 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==

"@types/cross-spawn@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@types/cross-spawn/-/cross-spawn-6.0.2.tgz#168309de311cd30a2b8ae720de6475c2fbf33ac7"
integrity sha512-KuwNhp3eza+Rhu8IFI5HUXRP0LIhqH5cAjubUvGXXthh4YYBuP2ntwEX+Cz8GJoZUHlKo247wPWOfA9LYEq4cw==
dependencies:
"@types/node" "*"

"@types/eslint-visitor-keys@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
Expand Down Expand Up @@ -2369,7 +2376,7 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"

cross-spawn@^7.0.0:
cross-spawn@^7.0.0, cross-spawn@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.2.tgz#d0d7dcfa74e89115c7619f4f721a94e1fdb716d6"
integrity sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==
Expand Down Expand Up @@ -7188,6 +7195,13 @@ universalify@^1.0.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
integrity sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug==

unixify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unixify/-/unixify-1.0.0.tgz#3a641c8c2ffbce4da683a5c70f03a462940c2090"
integrity sha1-OmQcjC/7zk2mg6XHDwOkYpQMIJA=
dependencies:
normalize-path "^2.1.1"

unset-value@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
Expand Down

0 comments on commit 5f5baab

Please sign in to comment.