Skip to content

Commit 0694741

Browse files
authored
test: Webpack integration tests (#904)
1 parent f57805a commit 0694741

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+913
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import { sentryConfig } from "../configs/after-upload-deletion.config.js";
3+
import { resolve } from "node:path";
4+
5+
export default {
6+
cache: false,
7+
entry: "./src/basic.js",
8+
output: {
9+
path: resolve("./out/after-upload-deletion"),
10+
filename: "basic.js",
11+
},
12+
devtool: "source-map",
13+
optimization: {
14+
minimize: false,
15+
},
16+
mode: "production",
17+
plugins: [sentryWebpackPlugin(sentryConfig)],
18+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="33730b8e-5b8d-4795-94b2-666cea28fce6",e._sentryDebugIdIdentifier="sentry-dbid-33730b8e-5b8d-4795-94b2-666cea28fce6");}catch(e){}}();
9+
/******/ (() => { // webpackBootstrap
10+
/******/ "use strict";
11+
// eslint-disable-next-line no-console
12+
console.log("hello world");
13+
14+
/******/ })()
15+
;
16+
//# sourceMappingURL=basic.js.map",
17+
}
18+
`);
19+
20+
const output = runFileInNode("basic.js");
21+
expect(output).toBe("hello world\n");
22+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import { sentryConfig } from "../configs/application-key.config.js";
3+
import { resolve } from "node:path";
4+
5+
export default {
6+
cache: false,
7+
entry: "./src/basic.js",
8+
output: {
9+
path: resolve("./out/application-key"),
10+
filename: "basic.js",
11+
},
12+
optimization: {
13+
minimize: false,
14+
},
15+
mode: "production",
16+
plugins: [sentryWebpackPlugin(sentryConfig)],
17+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],{"_sentryBundlerPluginAppKey:1234567890abcdef":true});var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}();
9+
/******/ (() => { // webpackBootstrap
10+
/******/ "use strict";
11+
// eslint-disable-next-line no-console
12+
console.log("hello world");
13+
14+
/******/ })()
15+
;",
16+
}
17+
`);
18+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import { sentryConfig } from "../configs/basic-release-disabled.config.js";
3+
import { resolve } from "node:path";
4+
5+
export default {
6+
cache: false,
7+
entry: "./src/basic.js",
8+
output: {
9+
path: resolve("./out/basic-release-disabled"),
10+
filename: "basic.js",
11+
},
12+
optimization: {
13+
minimize: false,
14+
},
15+
mode: "production",
16+
plugins: [sentryWebpackPlugin(sentryConfig)],
17+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}();
9+
/******/ (() => { // webpackBootstrap
10+
/******/ "use strict";
11+
// eslint-disable-next-line no-console
12+
console.log("hello world");
13+
14+
/******/ })()
15+
;",
16+
}
17+
`);
18+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import { sentryConfig } from "../configs/basic-sourcemaps.config.js";
3+
import { resolve } from "node:path";
4+
5+
export default {
6+
cache: false,
7+
entry: "./src/basic.js",
8+
output: {
9+
path: resolve("./out/basic-sourcemaps"),
10+
filename: "basic.js",
11+
},
12+
devtool: "source-map",
13+
optimization: {
14+
minimize: false,
15+
},
16+
mode: "production",
17+
plugins: [sentryWebpackPlugin(sentryConfig)],
18+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="33730b8e-5b8d-4795-94b2-666cea28fce6",e._sentryDebugIdIdentifier="sentry-dbid-33730b8e-5b8d-4795-94b2-666cea28fce6");}catch(e){}}();
9+
/******/ (() => { // webpackBootstrap
10+
/******/ "use strict";
11+
// eslint-disable-next-line no-console
12+
console.log("hello world");
13+
14+
/******/ })()
15+
;
16+
//# sourceMappingURL=basic.js.map",
17+
"basic.js.map": "{"version":3,"file":"basic.js","mappings":";;;AAAA;AACA","sources":["webpack://webpack5-integration-tests/./src/basic.js"],"sourcesContent":["// eslint-disable-next-line no-console\\nconsole.log(\\"hello world\\");\\n"],"names":[],"sourceRoot":""}",
18+
"sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
19+
["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
20+
["releases","finalize","CURRENT_SHA"],
21+
["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
22+
",
23+
}
24+
`);
25+
26+
const output = runFileInNode("basic.js");
27+
expect(output).toBe("hello world\n");
28+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { sentryWebpackPlugin } from "@sentry/webpack-plugin";
2+
import { sentryConfig } from "../configs/basic.config.js";
3+
import { resolve } from "node:path";
4+
5+
export default {
6+
cache: false,
7+
entry: "./src/basic.js",
8+
output: {
9+
path: resolve("./out/basic"),
10+
filename: "basic.js",
11+
},
12+
optimization: {
13+
minimize: false,
14+
},
15+
mode: "production",
16+
plugins: [sentryWebpackPlugin(sentryConfig)],
17+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { expect } from "vitest";
2+
import { test } from "./utils";
3+
4+
test(import.meta.url, ({ runBundler, readOutputFiles, runFileInNode }) => {
5+
runBundler();
6+
expect(readOutputFiles()).toMatchInlineSnapshot(`
7+
{
8+
"basic.js": "!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"CURRENT_SHA"};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6438758c-c236-4f8b-af24-575a5948a617",e._sentryDebugIdIdentifier="sentry-dbid-6438758c-c236-4f8b-af24-575a5948a617");}catch(e){}}();
9+
/******/ (() => { // webpackBootstrap
10+
/******/ "use strict";
11+
// eslint-disable-next-line no-console
12+
console.log("hello world");
13+
14+
/******/ })()
15+
;",
16+
"sentry-cli-mock.json": "["releases","new","CURRENT_SHA"],
17+
["releases","set-commits","CURRENT_SHA","--auto","--ignore-missing"],
18+
["releases","finalize","CURRENT_SHA"],
19+
["sourcemaps","upload","-p","fake-project","--release","CURRENT_SHA","sentry-bundler-plugin-upload-path","--ignore","node_modules","--no-rewrite"],
20+
",
21+
}
22+
`);
23+
24+
const output = runFileInNode("basic.js");
25+
expect(output).toBe("hello world\n");
26+
});

0 commit comments

Comments
 (0)