Skip to content

Commit 7e569dd

Browse files
Merge pull request #477 from preactjs/jest-matchers
Use jest matchers to better inspect mismatches
2 parents bbd06b5 + 2cb6470 commit 7e569dd

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/wmr/test/production.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,17 @@ describe('production', () => {
241241
const main = await fs.readFile(path.join(env.tmp.path, 'dist', roots[2]), 'utf8');
242242

243243
// https://cdn.example.com/assets/math.d41e7373.css
244-
expect(math.includes(`("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true);
245-
expect(math.includes(`import("./${chunks[0]}")`)).toBe(true);
244+
expect(math).toMatch(`("https://cdn.example.com/assets/${assets[1]}")`);
245+
expect(math).toMatch(`import("./${chunks[0]}")`);
246246

247247
// (preload) https://cdn.example.com/assets/math.d41e7373.css
248-
expect(main.includes(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true);
248+
expect(main).toMatch(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`);
249249

250250
// HTML stylesheet: https://cdn.example.com/assets/index.0544f0a6.css
251-
expect(html.includes(`href="https://cdn.example.com/assets/${assets[0]}"`)).toBe(true);
251+
expect(html).toMatch(`href="https://cdn.example.com/assets/${assets[0]}"`);
252252

253253
// HTML script: https://cdn.example.com/assets/index.0544f0a6.css
254-
expect(html.includes(`src="https://cdn.example.com/${roots[2]}"`)).toBe(true);
254+
expect(html).toMatch(`src="https://cdn.example.com/${roots[2]}"`);
255255
});
256256

257257
it('should respect `config.publicPath` value (ts)', async () => {
@@ -278,17 +278,17 @@ describe('production', () => {
278278
const main = await fs.readFile(path.join(env.tmp.path, 'dist', roots[2]), 'utf8');
279279

280280
// https://cdn.example.com/assets/math.d41e7373.css
281-
expect(math.includes(`("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true);
282-
expect(math.includes(`import("./${chunks[0]}")`)).toBe(true);
281+
expect(math).toMatch(`("https://cdn.example.com/assets/${assets[1]}")`);
282+
expect(math).toMatch(`import("./${chunks[0]}")`);
283283

284284
// (preload) https://cdn.example.com/assets/math.d41e7373.css
285-
expect(main.includes(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true);
285+
expect(main).toMatch(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`);
286286

287287
// HTML stylesheet: https://cdn.example.com/assets/index.0544f0a6.css
288-
expect(html.includes(`href="https://cdn.example.com/assets/${assets[0]}"`)).toBe(true);
288+
expect(html).toMatch(`href="https://cdn.example.com/assets/${assets[0]}"`);
289289

290290
// HTML script: https://cdn.example.com/assets/index.0544f0a6.css
291-
expect(html.includes(`src="https://cdn.example.com/${roots[2]}"`)).toBe(true);
291+
expect(html).toMatch(`src="https://cdn.example.com/${roots[2]}"`);
292292
});
293293
});
294294

0 commit comments

Comments
 (0)