Skip to content

Commit eba6e15

Browse files
committed
User test runner improvements
1 parent 16ceef5 commit eba6e15

File tree

5 files changed

+17
-28
lines changed

5 files changed

+17
-28
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ internal/
7272
yarn.lock
7373
yarn-error.log
7474
.parallelperf.*
75-
tests/cases/user/*/package-lock.json
7675
tests/cases/user/*/node_modules/
7776
tests/cases/user/*/**/*.js
7877
tests/cases/user/*/**/*.js.map

src/testRunner/externalCompileRunner.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,20 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
5555
ts.Debug.assert(!!config.cloneUrl, "Bad format from test.json: cloneUrl field must be present.");
5656
const submoduleDir = path.join(cwd, directoryName);
5757
if (!fs.existsSync(submoduleDir)) {
58-
exec("git", ["clone", config.cloneUrl, directoryName], { cwd });
58+
exec("git", ["--work-tree", submoduleDir, "clone", config.cloneUrl, path.join(submoduleDir, ".git")], { cwd });
59+
}
60+
else {
61+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "checkout", ":/"], { cwd: submoduleDir });
62+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "clean", "-f"], { cwd: submoduleDir });
63+
exec("git", ["--git-dir", path.join(submoduleDir, ".git"), "--work-tree", submoduleDir, "pull", "-f"], { cwd: submoduleDir });
5964
}
60-
exec("git", ["reset", "HEAD", "--hard"], { cwd: submoduleDir });
61-
exec("git", ["clean", "-f"], { cwd: submoduleDir });
62-
exec("git", ["pull", "-f"], { cwd: submoduleDir });
6365

6466
types = config.types;
6567

6668
cwd = config.path ? path.join(cwd, config.path) : submoduleDir;
6769
}
6870
if (fs.existsSync(path.join(cwd, "package.json"))) {
69-
if (fs.existsSync(path.join(cwd, "package-lock.json"))) {
71+
if (process.env.TRAVIS_EVENT_TYPE === "cron" && fs.existsSync(path.join(cwd, "package-lock.json"))) {
7072
fs.unlinkSync(path.join(cwd, "package-lock.json"));
7173
}
7274
if (fs.existsSync(path.join(cwd, "node_modules"))) {
@@ -75,7 +77,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase {
7577
exec("npm", ["i", "--ignore-scripts"], { cwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure
7678
}
7779
const args = [path.join(Harness.IO.getWorkspaceRoot(), "built/local/tsc.js")];
78-
if (types) {
80+
if (types?.length) {
7981
args.push("--types", types.join(","));
8082
// Also actually install those types (for, eg, the js projects which need node)
8183
exec("npm", ["i", ...types.map(t => `@types/${t}`), "--no-save", "--ignore-scripts"], { cwd: originalCwd, timeout: timeout / 2 }); // NPM shouldn't take the entire timeout - if it takes a long time, it should be terminated and we should log the failure

tests/baselines/reference/user/TypeScript-Vue-Starter.log

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/baselines/reference/user/TypeScript-WeChat-Starter.log

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
Exit Code: 1
22
Standard output:
3-
src/App.test.tsx(5,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
4-
src/components/Hello.test.tsx(5,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
5-
src/components/Hello.test.tsx(7,3): error TS2304: Cannot find name 'expect'.
6-
src/components/Hello.test.tsx(10,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
7-
src/components/Hello.test.tsx(12,3): error TS2304: Cannot find name 'expect'.
8-
src/components/Hello.test.tsx(15,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
9-
src/components/Hello.test.tsx(17,3): error TS2304: Cannot find name 'expect'.
10-
src/components/Hello.test.tsx(20,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
11-
src/components/Hello.test.tsx(21,3): error TS2304: Cannot find name 'expect'.
12-
src/components/Hello.test.tsx(26,1): error TS2593: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig.
13-
src/components/Hello.test.tsx(27,3): error TS2304: Cannot find name 'expect'.
3+
../../../../../node_modules/@types/mocha/index.d.ts(2680,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
4+
../../../../../node_modules/@types/mocha/index.d.ts(2698,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'afterEach' must be of type 'Lifecycle', but here has type 'HookFunction'.
5+
../../../../../node_modules/@types/mocha/index.d.ts(2714,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'describe' must be of type 'Describe', but here has type 'SuiteFunction'.
6+
../../../../../node_modules/@types/mocha/index.d.ts(2735,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'xdescribe' must be of type 'Describe', but here has type 'PendingSuiteFunction'.
7+
../../../../../node_modules/@types/mocha/index.d.ts(2749,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'it' must be of type 'It', but here has type 'TestFunction'.
8+
../../../../../node_modules/@types/mocha/index.d.ts(2763,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'test' must be of type 'It', but here has type 'TestFunction'.
9+
../../../../../node_modules/@types/mocha/index.d.ts(2770,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'xit' must be of type 'It', but here has type 'PendingTestFunction'.
1410

1511

1612

tests/baselines/reference/user/puppeteer.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Exit Code: 1
22
Standard output:
3+
../../../../../node_modules/@types/gulp/index.d.ts(9,27): error TS2307: Cannot find module 'chokidar'.
34
lib/Accessibility.js(134,15): error TS2503: Cannot find namespace 'Protocol'.
45
lib/Accessibility.js(344,7): error TS2322: Type 'string | number | boolean' is not assignable to type 'never'.
56
Type 'string' is not assignable to type 'never'.
@@ -55,7 +56,7 @@ lib/Page.js(94,33): error TS2345: Argument of type 'CDPSession' is not assignabl
5556
lib/Page.js(147,15): error TS2503: Cannot find namespace 'Protocol'.
5657
lib/Page.js(220,15): error TS2503: Cannot find namespace 'Protocol'.
5758
lib/Page.js(388,20): error TS2503: Cannot find namespace 'Protocol'.
58-
lib/Page.js(451,7): error TS2740: Type '(...args: any[]) => Promise<any>' is missing the following properties from type 'Window': applicationCache, caches, clientInformation, closed, and 223 more.
59+
lib/Page.js(451,7): error TS2740: Type '(...args: any[]) => Promise<any>' is missing the following properties from type 'Window': applicationCache, caches, clientInformation, closed, and 242 more.
5960
lib/Page.js(461,9): error TS2349: This expression is not callable.
6061
Type 'Window' has no call signatures.
6162
lib/Page.js(497,15): error TS2503: Cannot find namespace 'Protocol'.

0 commit comments

Comments
 (0)