22import './mocks' ;
33
44import * as fs from 'fs' ;
5+ import { describe , vi , it , expect } from 'vitest' ;
56
67import type { ModuleRuleUseProperty , WebpackModuleRule } from '../../src/config/types' ;
78import {
@@ -13,36 +14,8 @@ import {
1314} from './fixtures' ;
1415import { materializeFinalWebpackConfig } from './testUtils' ;
1516
16- const existsSyncSpy = jest . spyOn ( fs , 'existsSync' ) ;
17- const lstatSyncSpy = jest . spyOn ( fs , 'lstatSync' ) ;
18-
19- type MatcherResult = { pass : boolean ; message : ( ) => string } ;
20-
21- expect . extend ( {
22- stringEndingWith ( received : string , expectedEnding : string ) : MatcherResult {
23- const failsTest = ! received . endsWith ( expectedEnding ) ;
24- const generateErrorMessage = ( ) =>
25- failsTest
26- ? // Regular error message for match failing
27- `expected string ending with '${ expectedEnding } ', but got '${ received } '`
28- : // Error message for the match passing if someone has called it with `expect.not`
29- `expected string not ending with '${ expectedEnding } ', but got '${ received } '` ;
30-
31- return {
32- pass : ! failsTest ,
33- message : generateErrorMessage ,
34- } ;
35- } ,
36- } ) ;
37-
38- declare global {
39- // eslint-disable-next-line @typescript-eslint/no-namespace
40- namespace jest {
41- interface Expect {
42- stringEndingWith : ( expectedEnding : string ) => MatcherResult ;
43- }
44- }
45- }
17+ const existsSyncSpy = vi . spyOn ( fs , 'existsSync' ) ;
18+ const lstatSyncSpy = vi . spyOn ( fs , 'lstatSync' ) ;
4619
4720function applyRuleToResource ( rule : WebpackModuleRule , resourcePath : string ) : ModuleRuleUseProperty [ ] {
4821 const applications = [ ] ;
@@ -80,7 +53,7 @@ describe('webpack loaders', () => {
8053 test : expect . any ( RegExp ) ,
8154 use : [
8255 {
83- loader : expect . stringEndingWith ( ' valueInjectionLoader.js' ) ,
56+ loader : expect . stringMatching ( / v a l u e I n j e c t i o n L o a d e r \ .j s $ / ) ,
8457 // We use `expect.objectContaining({})` rather than `expect.any(Object)` to match any plain object because
8558 // the latter will also match arrays, regexes, dates, sets, etc. - anything whose `typeof` value is
8659 // `'object'`.
@@ -272,7 +245,7 @@ describe('webpack loaders', () => {
272245 test : / s e n t r y \. c l i e n t \. c o n f i g \. ( j s x ? | t s x ? ) / ,
273246 use : [
274247 {
275- loader : expect . stringEndingWith ( ' valueInjectionLoader.js' ) ,
248+ loader : expect . stringMatching ( / v a l u e I n j e c t i o n L o a d e r \ .j s $ / ) ,
276249 // We use `expect.objectContaining({})` rather than `expect.any(Object)` to match any plain object because
277250 // the latter will also match arrays, regexes, dates, sets, etc. - anything whose `typeof` value is
278251 // `'object'`.
@@ -285,9 +258,10 @@ describe('webpack loaders', () => {
285258} ) ;
286259
287260describe ( '`distDir` value in default server-side `RewriteFrames` integration' , ( ) => {
288- describe ( '`RewriteFrames` ends up with correct `distDir` value' , ( ) => {
261+ it ( '`RewriteFrames` ends up with correct `distDir` value' , ( ) => {
289262 // TODO: this, along with any number of other parts of the build process, should be tested with an integration
290263 // test which actually runs webpack and inspects the resulting bundles (and that integration test should test
291- // custom `distDir` values with and without a `.`, to make sure the regex escaping is working)
264+ // custom `distDir` values with and without a `.`, to make sure the regex
265+ // escaping is working)
292266 } ) ;
293267} ) ;
0 commit comments