From b356c78f460816bd027ccab7469b8c63d4f0c72e Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Sun, 28 Mar 2021 08:48:32 +0200 Subject: [PATCH] Use jest text matchers to better inspect mismatches --- packages/wmr/test/production.test.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/wmr/test/production.test.js b/packages/wmr/test/production.test.js index fd1f354a9..3646c6bc6 100644 --- a/packages/wmr/test/production.test.js +++ b/packages/wmr/test/production.test.js @@ -241,17 +241,17 @@ describe('production', () => { const main = await fs.readFile(path.join(env.tmp.path, 'dist', roots[2]), 'utf8'); // https://cdn.example.com/assets/math.d41e7373.css - expect(math.includes(`("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true); - expect(math.includes(`import("./${chunks[0]}")`)).toBe(true); + expect(math).toMatch(`("https://cdn.example.com/assets/${assets[1]}")`); + expect(math).toBe(`import("./${chunks[0]}")`); // (preload) https://cdn.example.com/assets/math.d41e7373.css - expect(main.includes(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true); + expect(main).toMatch(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`); // HTML stylesheet: https://cdn.example.com/assets/index.0544f0a6.css - expect(html.includes(`href="https://cdn.example.com/assets/${assets[0]}"`)).toBe(true); + expect(html).toMatch(`href="https://cdn.example.com/assets/${assets[0]}"`); // HTML script: https://cdn.example.com/assets/index.0544f0a6.css - expect(html.includes(`src="https://cdn.example.com/${roots[2]}"`)).toBe(true); + expect(html).toBe(`src="https://cdn.example.com/${roots[2]}"`); }); it('should respect `config.publicPath` value (ts)', async () => { @@ -278,17 +278,17 @@ describe('production', () => { const main = await fs.readFile(path.join(env.tmp.path, 'dist', roots[2]), 'utf8'); // https://cdn.example.com/assets/math.d41e7373.css - expect(math.includes(`("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true); - expect(math.includes(`import("./${chunks[0]}")`)).toBe(true); + expect(math).toMatch(`("https://cdn.example.com/assets/${assets[1]}")`); + expect(math).toMatch(`import("./${chunks[0]}")`); // (preload) https://cdn.example.com/assets/math.d41e7373.css - expect(main.includes(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`)).toBe(true); + expect(main).toMatch(`$w_s$("https://cdn.example.com/assets/${assets[1]}")`); // HTML stylesheet: https://cdn.example.com/assets/index.0544f0a6.css - expect(html.includes(`href="https://cdn.example.com/assets/${assets[0]}"`)).toBe(true); + expect(html).toBe(`href="https://cdn.example.com/assets/${assets[0]}"`); // HTML script: https://cdn.example.com/assets/index.0544f0a6.css - expect(html.includes(`src="https://cdn.example.com/${roots[2]}"`)).toBe(true); + expect(html).toMatch(`src="https://cdn.example.com/${roots[2]}"`); }); });