Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
refactor(experimental): delete Buffer in non-Node tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher committed Nov 17, 2023
1 parent fe489b3 commit aa45e91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/test-config/jest-unit.config.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const config: Partial<Config.InitialProjectOptions> = {
// this is required for @solana/compat, which uses the legacy web3js
moduleNameMapper: {
// Force module uuid to resolve with the CJS entry point, because Jest does not support package.json.exports. See https://github.com/uuidjs/uuid/issues/451
"uuid": require.resolve('uuid'),
uuid: require.resolve('uuid'),
},
setupFilesAfterEnv: [
...(commonConfig.setupFilesAfterEnv ?? []),
path.resolve(__dirname, 'setup-secure-context.ts'),
path.resolve(__dirname, 'setup-text-encoder.ts'),
path.resolve(__dirname, 'setup-web-buffer-global.ts'),
],
testEnvironment: 'jsdom',
testEnvironmentOptions: {},
Expand Down
8 changes: 8 additions & 0 deletions packages/test-config/setup-web-buffer-global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Browsers don't have a `Buffer` global, so delete it now.
*/
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delete globalThis.Buffer;
});

0 comments on commit aa45e91

Please sign in to comment.