Skip to content

Commit 31d27c4

Browse files
committed
use matchInlineSnapshot fn
1 parent d7cb964 commit 31d27c4

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

packages/bundler-plugin-core/test/index.test.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ describe("createRollupDebugIdInjectionHooks", () => {
2323
const result = hooks.renderChunk(code, { fileName: "bundle.js" });
2424

2525
expect(result).not.toBeNull();
26-
expect(result?.code).toContain("_sentryDebugIdIdentifier");
27-
expect(result?.code).toContain('console.log("Hello world");');
26+
expect(result?.code).toMatchInlineSnapshot(
27+
`";{try{(function(){var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\\"d4309f93-5358-4ae1-bcf0-3813aa590eb5\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-d4309f93-5358-4ae1-bcf0-3813aa590eb5\\");})();}catch(e){}};console.log(\\"Hello world\\");"`
28+
);
2829
});
2930

3031
it("should inject debug ID after 'use strict'", () => {
3132
const code = '"use strict";\nconsole.log("Hello world");';
3233
const result = hooks.renderChunk(code, { fileName: "bundle.js" });
3334

3435
expect(result).not.toBeNull();
35-
expect(result?.code).toMatch(/^"use strict";.*;{try/);
36+
expect(result?.code).toMatchInlineSnapshot(`
37+
"\\"use strict\\";;{try{(function(){var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\\"79a86c07-8ecc-4367-82b0-88cf822f2d41\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-79a86c07-8ecc-4367-82b0-88cf822f2d41\\");})();}catch(e){}};
38+
console.log(\\"Hello world\\");"
39+
`);
3640
});
3741

3842
it.each([
@@ -46,7 +50,9 @@ describe("createRollupDebugIdInjectionHooks", () => {
4650
const result = hooks.renderChunk(code, { fileName });
4751

4852
expect(result).not.toBeNull();
49-
expect(result?.code).toContain("_sentryDebugIdIdentifier");
53+
expect(result?.code).toMatchInlineSnapshot(
54+
`";{try{(function(){var e=\\"undefined\\"!=typeof window?window:\\"undefined\\"!=typeof global?global:\\"undefined\\"!=typeof globalThis?globalThis:\\"undefined\\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\\"b80112c0-6818-486d-96f0-185c023439b4\\",e._sentryDebugIdIdentifier=\\"sentry-dbid-b80112c0-6818-486d-96f0-185c023439b4\\");})();}catch(e){}};console.log(\\"test\\");"`
55+
);
5056
});
5157

5258
it.each([["index.html"], ["styles.css"]])("should NOT process file '%s': %s", (fileName) => {

0 commit comments

Comments
 (0)