Skip to content

Commit 434c7a2

Browse files
authored
test: fix e2e tests (#856)
* chore: switch to yarn 4 * refactor: remove unused enabled field from ts config * refactor: fix type error from nullable type * test: update unit tests to not check unsupported options * test: update tests to handle colors from code-frame package * test: remove assertion to support new behaviour of webpack * chore: update ci workflow * chore: update yarn version in config * chore: update workflwo commands * chore: upgrade node version in ci workflow * chore: update lock file after changes * chore: disable immutable installs in e2e tests * test: disable solution builder test * test: use different hash function because of ssl breaking change * test: update cwd test * test: update type-definitions test * test: update webpack node api test
1 parent 0fab463 commit 434c7a2

29 files changed

+11593
-8173
lines changed

.github/workflows/main.yml

Lines changed: 37 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,17 @@ jobs:
1111
- name: Setup node
1212
uses: actions/setup-node@v4
1313
with:
14-
node-version: 16
15-
16-
- name: Yarn cache directory
17-
id: yarn-cache
18-
run: echo "::set-output name=dir::$(yarn cache dir)"
19-
20-
- name: Yarn cache
21-
uses: actions/cache@v4
22-
with:
23-
path: ${{ steps.yarn-cache.outputs.dir }}
24-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
25-
restore-keys: |
26-
${{ runner.os }}-yarn-
14+
node-version: 20
15+
cache: 'yarn'
2716

2817
- name: Install dependencies
29-
run: yarn install --frozen-lockfile
18+
run: yarn install --immutable
3019

3120
- name: Build project
3221
run: yarn build
3322

3423
- name: Upload build artifact
35-
uses: actions/upload-artifact@v3
24+
uses: actions/upload-artifact@v4
3625
with:
3726
name: lib
3827
path: lib
@@ -42,49 +31,38 @@ jobs:
4231
needs: build
4332
strategy:
4433
matrix:
45-
node: [14, 16]
34+
node: [18, 20]
4635
os: [ubuntu-latest, macos-latest, windows-latest]
4736
fail-fast: false
4837
steps:
49-
- uses: actions/checkout@v4
50-
51-
- name: Setup node
52-
uses: actions/setup-node@v4
53-
with:
54-
node-version: ${{ matrix.node }}
55-
56-
- name: Yarn cache directory
57-
id: yarn-cache
58-
run: echo "::set-output name=dir::$(yarn cache dir)"
59-
60-
- name: Yarn cache
61-
uses: actions/cache@v4
62-
with:
63-
path: ${{ steps.yarn-cache.outputs.dir }}
64-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
65-
restore-keys: |
66-
${{ runner.os }}-yarn-
67-
68-
- name: Locks cache
69-
uses: actions/cache@v4
70-
with:
71-
path: test/e2e/__locks__
72-
key: ${{ runner.os }}-locks
73-
74-
- name: Install dependencies
75-
run: yarn install --frozen-lockfile
76-
77-
- name: Download build artifact
78-
uses: actions/download-artifact@v3
79-
with:
80-
name: lib
81-
path: lib
82-
83-
- name: Run unit tests
84-
run: yarn test:unit
85-
86-
- name: Run e2e tests
87-
run: yarn test:e2e
38+
- uses: actions/checkout@v4
39+
40+
- name: Setup node
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node }}
44+
cache: 'yarn'
45+
46+
- name: Locks cache
47+
uses: actions/cache@v4
48+
with:
49+
path: test/e2e/__locks__
50+
key: ${{ runner.os }}-locks
51+
52+
- name: Install dependencies
53+
run: yarn install --immutable
54+
55+
- name: Download build artifact
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: lib
59+
path: lib
60+
61+
- name: Run unit tests
62+
run: yarn test:unit
63+
64+
- name: Run e2e tests
65+
run: yarn test:e2e
8866

8967
release:
9068
runs-on: ubuntu-latest
@@ -101,13 +79,14 @@ jobs:
10179
- name: Setup node
10280
uses: actions/setup-node@v4
10381
with:
104-
node-version: 16
82+
node-version: 20
83+
cache: 'yarn'
10584

10685
- name: Install dependencies
107-
run: yarn install --frozen-lockfile
86+
run: yarn install --immutable
10887

10988
- name: Download build artifact
110-
uses: actions/download-artifact@v3
89+
uses: actions/download-artifact@v4
11190
with:
11291
name: lib
11392
path: lib

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,17 @@
44
"javascriptreact",
55
"typescript",
66
"typescriptreact"
7+
],
8+
"jest.virtualFolders": [
9+
{
10+
"name": "test/e2e",
11+
"jestCommandLine": "npm pack && yarn jest --config=test/e2e/jest.config.js --ci -i -b",
12+
"runMode": "on-demand"
13+
},
14+
{
15+
"name": "test/unit",
16+
"jestCommandLine": "yarn jest --config=test/unit/jest.config.js",
17+
"runMode": "on-demand"
18+
}
719
]
820
}

.yarn/install-state.gz

997 KB
Binary file not shown.

.yarn/releases/yarn-4.7.0.cjs

Lines changed: 935 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-4.7.0.cjs

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"lint": "cross-env eslint ./src ./test --ext .ts",
3636
"test": "yarn build && yarn test:unit && yarn test:e2e",
3737
"test:unit": "cross-env jest --config=test/unit/jest.config.js",
38-
"test:e2e": "npm pack && cross-env jest --config=test/e2e/jest.config.js --ci -i -b",
38+
"test:e2e": "npm pack && cross-env YARN_ENABLE_IMMUTABLE_INSTALLS=false jest --config=test/e2e/jest.config.js --ci -i -b",
3939
"precommit": "cross-env lint-staged && yarn build && yarn test:unit",
4040
"commit": "cross-env git-cz",
4141
"semantic-release": "semantic-release",
@@ -115,7 +115,7 @@
115115
"webpack": "^5.67.0"
116116
},
117117
"engines": {
118-
"node": ">=12.13.0",
119-
"yarn": ">=1.0.0"
120-
}
118+
"node": ">=12.13.0"
119+
},
120+
"packageManager": "[email protected]"
121121
}

src/typescript/type-script-worker-config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-opt
77
import type { TypeScriptWorkerOptions } from './type-script-worker-options';
88

99
interface TypeScriptWorkerConfig {
10-
enabled: boolean;
1110
memoryLimit: number;
1211
configFile: string;
1312
configOverwrite: TypeScriptConfigOverwrite;
@@ -23,8 +22,7 @@ function createTypeScriptWorkerConfig(
2322
compiler: webpack.Compiler,
2423
options: TypeScriptWorkerOptions | undefined
2524
): TypeScriptWorkerConfig {
26-
let configFile =
27-
typeof options === 'object' ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
25+
let configFile = options?.configFile || 'tsconfig.json';
2826

2927
// ensure that `configFile` is an absolute normalized path
3028
configFile = path.normalize(
@@ -39,7 +37,6 @@ function createTypeScriptWorkerConfig(
3937
const typescriptPath = optionsAsObject.typescriptPath || require.resolve('typescript');
4038

4139
return {
42-
enabled: options !== false,
4340
memoryLimit: 2048,
4441
build: false,
4542
mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',

src/watch/watch-file-system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface Watchpack extends EventEmitter {
88
_onRemove(item: string, file: string, type?: string): void;
99
}
1010

11-
type Watch = webpack.Compiler['watchFileSystem']['watch'];
11+
type Watch = NonNullable<webpack.Compiler['watchFileSystem']>['watch'];
1212

1313
interface WatchFileSystem {
1414
watcher?: Watchpack;

test/e2e/fixtures/type-definitions/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"main": "dist/index.js",
55
"license": "MIT",
66
"devDependencies": {
7-
"typescript": "~4.9.0",
8-
"webpack": "^5.11.0"
7+
"@types/node": "^18.11.9",
8+
"typescript": "~5.8.0",
9+
"webpack": "^5.98.0"
910
}
1011
}

test/e2e/fixtures/type-definitions/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "es2020",
44
"module": "commonjs",
55
"lib": ["ES6", "DOM"],
66
"moduleResolution": "node",

0 commit comments

Comments
 (0)