Skip to content

Commit d0343b6

Browse files
authored
chore: bump vitest deps (#5622)
* chore: bump vitest deps * chore: fix linting errors
1 parent 6a7c0ad commit d0343b6

File tree

11 files changed

+146
-248
lines changed

11 files changed

+146
-248
lines changed

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
"release:publish": "./scripts/release/publish.sh",
3535
"release:publish:canary": "nx release publish --registry https://registry.npmjs.org --tag canary"
3636
},
37-
"//": {
38-
"vitest": "Pinning to v3.2.4 since v4 upgrade is breaking some tests"
39-
},
4037
"devDependencies": {
4138
"@commitlint/cli": "^20.1.0",
4239
"@eslint/js": "9.39.1",
@@ -53,10 +50,10 @@
5350
"@swc/helpers": "~0.5.17",
5451
"@types/babel__core": "^7.20.5",
5552
"@types/node": "^22.19.1",
56-
"@vitest/coverage-v8": "3.2.4",
57-
"@vitest/eslint-plugin": "1.4.3",
58-
"@vitest/spy": "4.0.13",
59-
"@vitest/ui": "3.2.4",
53+
"@vitest/coverage-v8": "4.0.14",
54+
"@vitest/eslint-plugin": "1.5.1",
55+
"@vitest/spy": "4.0.14",
56+
"@vitest/ui": "4.0.14",
6057
"bytes": "^3.1.2",
6158
"es-module-lexer": "^1.7.0",
6259
"eslint": "9.39.1",
@@ -77,7 +74,7 @@
7774
"tslib": "^2.8.1",
7875
"typescript": "5.8.2",
7976
"typescript-eslint": "8.47.0",
80-
"vitest": "3.2.4"
77+
"vitest": "4.0.14"
8178
},
8279
"lint-staged": {
8380
"*.{js,mjs,ts,only,skip}": "eslint --cache",

packages/@lwc/compiler/src/transformers/__tests__/transform-html.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ describe('transformSync', () => {
7979
...config,
8080
});
8181
expect(warnings!.length).toBe(0);
82-
if (expected) {
83-
expect(code).toContain('<img');
84-
} else {
85-
expect(code).not.toContain('<img');
86-
}
82+
expect(code.includes('<img')).toBe(expected);
8783
});
8884
});
8985

packages/@lwc/compiler/src/transformers/__tests__/transform-javascript.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ describe('object rest spread', () => {
6060
});
6161

6262
expect(code).toContain('b: 1');
63-
if (apiVersion === 59) {
64-
expect(code).not.toContain('...a');
65-
} else {
66-
expect(code).toContain('...a');
67-
}
63+
const shouldContainSpread = apiVersion !== 59;
64+
expect(code.includes('...a')).toBe(shouldContainSpread);
6865
});
6966
});
7067
});

packages/@lwc/errors/src/compiler/__tests__/error-info.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ it('errors with strictLevel have correct DiagnosticLevel.Fatal value', () => {
6565

6666
// Check GENERIC_COMPILER_ERROR
6767
if (fatalErrorCodes.includes(GENERIC_COMPILER_ERROR.code)) {
68+
// eslint-disable-next-line vitest/no-conditional-expect
6869
expect(GENERIC_COMPILER_ERROR.strictLevel).toBe(DiagnosticLevel.Fatal);
6970
}
7071

7172
// Check all other errors
7273
Object.entries(errors).forEach(([_key, map]) => {
7374
Object.entries(map).forEach(([_label, info]) => {
7475
if (fatalErrorCodes.includes(info.code)) {
76+
// eslint-disable-next-line vitest/no-conditional-expect
7577
expect(info.strictLevel).toBe(DiagnosticLevel.Fatal);
7678
}
7779
});

packages/@lwc/features/src/__tests__/setFeatureFlag.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@ describe('setFeatureFlag', () => {
3636
// @ts-expect-error Explicitly testing JS behavior that violates TS types
3737
setFeatureFlag('PLACEHOLDER_TEST_FLAG', 'foo');
3838
};
39+
3940
if (env === 'production') {
4041
callback();
42+
// eslint-disable-next-line vitest/no-conditional-expect
4143
expect(error).toHaveBeenCalledExactlyOnceWith(expectedError);
4244
} else {
45+
// eslint-disable-next-line vitest/no-conditional-expect
4346
expect(callback).toThrowError(expectedError);
4447
}
4548

@@ -64,12 +67,16 @@ describe('setFeatureFlag', () => {
6467
expect(lwcRuntimeFlags.PLACEHOLDER_TEST_FLAG).toEqual(true);
6568
setFeatureFlag('PLACEHOLDER_TEST_FLAG', false);
6669
if (env === 'production') {
70+
// eslint-disable-next-line vitest/no-conditional-expect
6771
expect(error).toHaveBeenCalledExactlyOnceWith(
6872
'Failed to set the value "false" for the runtime feature flag "PLACEHOLDER_TEST_FLAG". "PLACEHOLDER_TEST_FLAG" has already been set with the value "true".'
6973
);
74+
// eslint-disable-next-line vitest/no-conditional-expect
7075
expect(lwcRuntimeFlags.PLACEHOLDER_TEST_FLAG).toEqual(true);
7176
} else {
77+
// eslint-disable-next-line vitest/no-conditional-expect
7278
expect(error).not.toHaveBeenCalled();
79+
// eslint-disable-next-line vitest/no-conditional-expect
7380
expect(lwcRuntimeFlags.PLACEHOLDER_TEST_FLAG).toEqual(false);
7481
}
7582
});

packages/@lwc/integration-wtr/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"@lwc/synthetic-shadow": "8.26.0",
1818
"@types/chai": "^5.2.3",
1919
"@types/jasmine": "^5.1.13",
20-
"@vitest/expect": "^4.0.13",
21-
"@vitest/spy": "^4.0.13",
20+
"@vitest/expect": "^4.0.14",
21+
"@vitest/spy": "^4.0.14",
2222
"@web/dev-server-import-maps": "^0.2.1",
2323
"@web/dev-server-rollup": "^0.6.4",
2424
"@web/test-runner": "^0.20.2",

packages/@lwc/rollup-plugin/src/__tests__/enableStaticContentOptimization/enableStaticContentOptimization.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ describe('enableStaticContentOptimization:', () => {
5050
it.for(configs)('$name', async ({ opts, expected }) => {
5151
const { code, warnings } = await runRollup('fixtures/basic/basic.js', opts);
5252
expect(warnings).toEqual([]);
53-
if (expected) {
54-
expect(code).toContain('<img');
55-
} else {
56-
expect(code).not.toContain('<img');
57-
}
53+
expect(code.includes('<img')).toBe(expected);
5854
});
5955
});

packages/@lwc/ssr-compiler/src/__tests__/dynamic-imports.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('dynamic imports', () => {
5050
};
5151

5252
if (strictSpecifier && !isStrict) {
53+
// eslint-disable-next-line vitest/no-conditional-expect
5354
expect(callback).toThrowError(/LWC1121/);
5455
return;
5556
} else {
@@ -65,8 +66,10 @@ describe('dynamic imports', () => {
6566
]);
6667

6768
if (loader) {
69+
// eslint-disable-next-line vitest/no-conditional-expect
6870
expect(imports).toEqual(importsWithLoader);
6971
} else {
72+
// eslint-disable-next-line vitest/no-conditional-expect
7073
expect(imports).not.toEqual(importsWithLoader);
7174
}
7275
}

packages/@lwc/template-compiler/src/__tests__/index.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ describe('parse', () => {
7979
const template = `<template><img src="http://example.com/img.png" crossorigin="anonymous"></template>`;
8080
const { code, warnings } = compile(template, '', config);
8181
expect(warnings.length).toBe(0);
82-
if (expected) {
83-
expect(code).toContain('<img');
84-
} else {
85-
expect(code).not.toContain('<img');
86-
}
82+
expect(code.includes('<img')).toBe(expected);
8783
});
8884
});
8985
});

packages/lwc/__tests__/default-exports.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ describe('default exports are not forgotten', () => {
6666
`^export \\{ default \\} from '@lwc/${pkg}';$`,
6767
'm'
6868
);
69+
// eslint-disable-next-line vitest/no-conditional-expect
6970
expect(readPackageFile(pkg, '.d.ts')).toMatch(exportDefaultFromPackage);
71+
// eslint-disable-next-line vitest/no-conditional-expect
7072
expect(readPackageFile(pkg, '.js')).toMatch(exportDefaultFromPackage);
7173
}
7274
});

0 commit comments

Comments
 (0)