Skip to content

Commit

Permalink
test: polyfill missing method
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpedemonte committed Jul 23, 2024
1 parent a34f72b commit cd3a6bd
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions examples/discovery-search-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
"devDependencies": {
"@testing-library/cypress": "^7.0.7",
"@types/proper-url-join": "^2.1.4",
"core-js": "^3.37.1",
"cross-env": "^7.0.3",
"cypress": "^13.6.3",
"react-scripts": "^5.0.1",
"start-server-and-test": "^2.0.3"
},
"jest": {
"displayName": "Search app (unit)",
"moduleNameMapper": {
"^axios$": "axios/dist/node/axios.cjs"
}
Expand Down
6 changes: 6 additions & 0 deletions examples/discovery-search-app/src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Set up `jest` when run from `react-scripts`
*/

// polyfill for `Promise.withResolvers()`
import 'core-js/proposals/promise-with-resolvers';
6 changes: 5 additions & 1 deletion packages/discovery-react-components/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StorybookConfig } from '@storybook/react-vite';
import path from 'node:path';
import { mergeConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';

Expand All @@ -23,7 +24,10 @@ const config: StorybookConfig = {
disableTelemetry: true
},

staticDirs: ['../../../node_modules/pdfjs-dist/build/'],
staticDirs: [
// should resolve to '.../pdfjs-dist/build/'
path.dirname(require.resolve('pdfjs-dist'))
],

framework: '@storybook/react-vite',

Expand Down
7 changes: 2 additions & 5 deletions packages/discovery-react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
},
"jest": {
"resetMocks": false,
"displayName": "Disco React Components (Unit)",
"displayName": "Disco React Components (unit)",
"transformIgnorePatterns": [
"/!node_modules\\/react-virtualized/"
],
Expand All @@ -109,9 +109,6 @@
"!src/**/__fixtures__/**",
"!src/**/__stories__/**",
"!src/**/*.stories.*"
],
"moduleNameMapper": {
"^pdfjs-dist$": "pdfjs-dist/legacy/build/pdf.mjs"
}
]
}
}
6 changes: 6 additions & 0 deletions packages/discovery-react-components/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/**
* Set up `jest` when run from `react-scripts`
*/

import '@testing-library/jest-dom/extend-expect';
// polyfill for `Promise.withResolvers()`
import 'core-js/proposals/promise-with-resolvers';
import setPdfJsGlobalWorkerOptions from 'utils/setPdfJsGlobalWorkerOptions';

// Set pdf.js worker for all tests
Expand Down
9 changes: 5 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10130,10 +10130,10 @@ __metadata:
languageName: node
linkType: hard

"core-js@npm:^3.19.2, core-js@npm:^3.29.0":
version: 3.33.3
resolution: "core-js@npm:3.33.3"
checksum: 10c0/08abdc9470c8228b9d09f61e62ab312738681202c4c34e9638889125b304b235f34c4fe22e9d41c20906ac0fcc807dca57c5ff7d6b90021bf64e8fe23461d9ab
"core-js@npm:^3.19.2, core-js@npm:^3.29.0, core-js@npm:^3.37.1":
version: 3.37.1
resolution: "core-js@npm:3.37.1"
checksum: 10c0/440eb51a7a39128a320225fe349f870a3641b96c9ecd26470227db730ef8c161ea298eaea621db66ec0ff622a85299efb4e23afebf889c0a1748616102307675
languageName: node
linkType: hard

Expand Down Expand Up @@ -11319,6 +11319,7 @@ __metadata:
carbon-components-react: "npm:7.59.24"
carbon-icons: "npm:^7.0.7"
classnames: "npm:^2.5.1"
core-js: "npm:^3.37.1"
cors: "npm:^2.8.5"
cross-env: "npm:^7.0.3"
cypress: "npm:^13.6.3"
Expand Down

0 comments on commit cd3a6bd

Please sign in to comment.