diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 271c1f2d8adf..32782ff1b1a6 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -86,7 +86,10 @@ "tsConfig": "./tsconfig.json", "diagnostics": false } - } + }, + "setupFiles": [ + "/test/setEnvVars.ts" + ] }, "sideEffects": false } diff --git a/packages/gatsby/test/gatsby-node.test.ts b/packages/gatsby/test/gatsby-node.test.ts index bf0988b123c5..f09f8e5be781 100644 --- a/packages/gatsby/test/gatsby-node.test.ts +++ b/packages/gatsby/test/gatsby-node.test.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-explicit-any */ - const { onCreateWebpackConfig } = require('../gatsby-node'); describe('onCreateWebpackConfig', () => { @@ -18,7 +17,7 @@ describe('onCreateWebpackConfig', () => { expect(plugins.define).toHaveBeenCalledTimes(1); expect(plugins.define).toHaveBeenLastCalledWith({ __SENTRY_DSN__: expect.any(String), - __SENTRY_RELEASE__: undefined, + __SENTRY_RELEASE__: expect.any(String), }); expect(actions.setWebpackConfig).toHaveBeenCalledTimes(1); diff --git a/packages/gatsby/test/setEnvVars.ts b/packages/gatsby/test/setEnvVars.ts new file mode 100644 index 000000000000..9e9c7898cbfd --- /dev/null +++ b/packages/gatsby/test/setEnvVars.ts @@ -0,0 +1,2 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +process.env.SENTRY_RELEASE = '14abbb1678a2eb59d1a171ea33d630dd6c6eee70';