Skip to content

Commit

Permalink
moduleNameMapper only for browser
Browse files Browse the repository at this point in the history
  • Loading branch information
denysoblohin-okta committed May 25, 2022
1 parent 05f3d56 commit ea33627
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions jest.esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

//Jest doc: https://jestjs.io/docs/ecmascript-modules

const OktaAuth = process.env.BUNDLE_ENV === 'browser' ?
`<rootDir>/build/bundles-for-validation/esm/esm.browser.mjs` :
`<rootDir>/build/esm/esm.node.mjs`;
const testEnvironment = process.env.BUNDLE_ENV === 'browser' ? 'jsdom' : 'node';
const moduleNameMapper = process.env.BUNDLE_ENV === 'browser' ? {
'^@okta/okta-auth-js$': `<rootDir>/build/bundles-for-validation/esm/esm.browser.mjs`,
'^broadcast-channel$': '<rootDir>/node_modules/broadcast-channel/dist/esnode/index.mjs'
} : {};

export default {
roots: [
Expand All @@ -27,10 +28,7 @@ export default {
],
transform: {},
restoreMocks: true,
moduleNameMapper: {
'^@okta/okta-auth-js$': OktaAuth,
'^broadcast-channel$': '<rootDir>/node_modules/broadcast-channel/dist/esnode/index.mjs'
},
moduleNameMapper,
extensionsToTreatAsEsm: ['.ts'],
testPathIgnorePatterns: [],
reporters: [
Expand Down

0 comments on commit ea33627

Please sign in to comment.