Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinnnnn committed Apr 18, 2024
1 parent 4c4eb63 commit 7da23fc
Show file tree
Hide file tree
Showing 4 changed files with 879 additions and 532 deletions.
18 changes: 16 additions & 2 deletions apps/web/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@ module.exports = async () => {

// Rainbow kit and nextjs-routes ship code which is not transpiled. We have to tell Jest to transpile it
// https://stackoverflow.com/questions/55794280/jest-fails-with-unexpected-token-on-import-statement
const modulesToTranspile = ['nextjs-routes', '@rainbow-me/rainbowkit'];
const modulesToTranspile = [
'nextjs-routes',
'@rainbow-me/rainbowkit',
'ofetch',
'jose',
'@privy-io/react-auth',
'@coinbase/wallet-sdk',
'preact',
'uint8arrays',
'multiformats',
];

return {
...nextJestConfig,

transformIgnorePatterns: [`node_modules/(?!(${modulesToTranspile.join('|')})/)`],
transformIgnorePatterns: [
`node_modules/(?!(${modulesToTranspile.join('|')})/)`,
// '/node_modules/(?!ofetch)',
// '/node_modules/(?!nextjs-routes)',
],
};
};
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
"@types/styled-components": "5.1.9",
"@types/uuid": "^8.3.4",
"@types/webpack-env": "^1.18.0",
"crypto-browserify": "^3.12.0",
"cypress": "^10.7.0",
"eslint-config-next": "^13.1.6",
"graphql": "^16.8.1",
"identity-obj-proxy": "^3.0.0",
"jest": "28.1.0",
"jest": "29.7.0",
"jest-environment-jsdom": "28.1.0",
"jsdom": "^20.0.0",
"madge": "^5.0.1",
Expand Down
8 changes: 8 additions & 0 deletions apps/web/tests/setupFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ jest.mock('next/dist/shared/lib/router-context.shared-runtime', () => {
const RouterContext = createContext(router);
return { RouterContext };
});

import { createRequire } from 'module';
const require = createRequire(import.meta.url);
global.crypto = require('crypto').webcrypto;

import { TextDecoder, TextEncoder } from 'util';
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
Loading

0 comments on commit 7da23fc

Please sign in to comment.