Skip to content

Commit

Permalink
Port relevant tests to Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0grog authored and jackocnr committed Oct 5, 2024
1 parent 557cbf5 commit 866cbf9
Show file tree
Hide file tree
Showing 11 changed files with 606 additions and 556 deletions.
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Jest uses the `vm` module, which does not have production ready module support
# yet. This option lets us use dynamic imports.
node-options='--experimental-vm-modules'
24 changes: 24 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @type {import('jest').Config} */
module.exports = {
moduleDirectories: [
"node_modules",
"build/js",
],
transform: {
// Most of the build outputs in this project use UMD syntax, but the
// utilities script is a proper ES Module. Unfortunately, Jest cannot treat
// a file with a `.js` extension as ESM unless the whole project is ESM
// (Jest does not use Node.js built-in resolution and loading logic), so
// we have to set up special parsing for that file.
// See also: https://jestjs.io/docs/next/ecmascript-modules
"utils.js$": [
"babel-jest",
{
plugins: [
"@babel/plugin-transform-modules-commonjs",
"babel-plugin-add-module-exports",
],
},
],
},
};
392 changes: 175 additions & 217 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"license": "MIT",
"author": "Jack O'Connor (http://jackocnr.com)",
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/user-event": "^14.5.2",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"@vitejs/plugin-vue": "^5.1.2",
"babel-plugin-add-module-exports": "^1.0.4",
"cspell": "^8.6.1",
"esbuild": "^0.23.0",
"eslint": "^8.57.0",
Expand Down Expand Up @@ -152,11 +154,5 @@
"react/build/IntlTelInput.d.ts"
]
}
},
"jest": {
"moduleDirectories": [
"node_modules",
"build/js"
]
}
}
4 changes: 0 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@

<script src="src/spec/tests/options/initialCountry.js"></script>

<script src="src/spec/tests/options/loadUtilsOnInit.js"></script>

<script src="src/spec/tests/options/nationalMode.js"></script>

<script src="src/spec/tests/options/onlyCountries.js"></script>
Expand All @@ -88,8 +86,6 @@

<script src="src/spec/tests/static/getCountryData.js"></script>

<script src="src/spec/tests/static/loadUtils.js"></script>

<script src=".grunt/grunt-contrib-jasmine/reporter.js"></script>


Expand Down
105 changes: 0 additions & 105 deletions src/spec/tests/options/loadUtilsOnInit.js

This file was deleted.

217 changes: 0 additions & 217 deletions src/spec/tests/static/loadUtils.js

This file was deleted.

Loading

0 comments on commit 866cbf9

Please sign in to comment.