Skip to content

Commit

Permalink
Enable Jest tests in *.mjs files
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Mar 1, 2023
1 parent f1f1001 commit ff38f6d
Show file tree
Hide file tree
Showing 6 changed files with 13,150 additions and 10,769 deletions.
7 changes: 0 additions & 7 deletions .babelrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ last 2 versions
ie 8
ie 9
iOS 9

[node]
node 18
20 changes: 20 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Babel config
*
* @type {import('@babel/core').ConfigFunction}
*/
module.exports = function (api) {
const browserslistEnv = !api.env('test')
? 'production'
: 'node'

const presets = [
['@babel/preset-env', {
browserslistEnv
}]
]

return {
presets
}
}
5 changes: 5 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export default {
// Test timeout increased (5s to 15s)
testTimeout: 15000,

// Enable Babel transforms until Jest supports ESM
// See: https://jestjs.io/docs/ecmascript-modules
testMatch: ['**/*.test.{js,mjs}'],
transform: { '^.+\\.m?js$': ['babel-jest'] },

// Ignore built fixtures during `--watch`
watchPathIgnorePatterns: ['fixtures/build']
}
Loading

0 comments on commit ff38f6d

Please sign in to comment.