Skip to content

Commit

Permalink
update js dependencies, move to jest for testing (#5821)
Browse files Browse the repository at this point in the history
* update js dependencies, move to jest for testing

This commit updates the js dependencies to the latest versions and moves
from mocha to jest for testing. This is consistent with the setup we
use in LiveView.

* run npm tests on node 20
  • Loading branch information
SteffenDE authored Jun 14, 2024
1 parent e336b25 commit be4eb9a
Show file tree
Hide file tree
Showing 11 changed files with 8,473 additions and 13,566 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ jobs:
restore-keys: |
deps-${{ runner.os }}-npm
- name: Set up Node.js 12.x
- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 12.x
node-version: 20.x

- name: Restore npm cache
uses: actions/cache@v4
Expand Down
17 changes: 8 additions & 9 deletions assets/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ module.exports = {
"env": {
"browser": true,
"es2021": true,
"jest/globals": true
},
"extends": "eslint:recommended",
"globals": {
"global": "writable"
},
"extends": [
"eslint:recommended",
"plugin:mocha/recommended"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"mocha"
"jest"
],
"rules": {
"indent": [
Expand Down Expand Up @@ -75,8 +76,6 @@ module.exports = {
],
"no-useless-escape": "off",
"no-cond-assign": "off",
"no-case-declarations": "off",
"mocha/no-skipped-tests": "off",
"mocha/max-top-level-suites": "off"
"no-case-declarations": "off"
}
}
}
1 change: 1 addition & 0 deletions assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/coverage/
27 changes: 27 additions & 0 deletions assets/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

module.exports = {
// Automatically clear mock calls and instances between every test
clearMocks: true,

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: [
// "<rootDir>/setupTests.js"
],

// The test environment that will be used for testing
testEnvironment: "jest-environment-jsdom-global",

testEnvironmentOptions: {
url: "https://example.com"
},

// The regexp pattern or array of patterns that Jest uses to detect test files
testRegex: "/test/.*_test\\.js$",
};
2 changes: 1 addition & 1 deletion assets/js/phoenix/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export default class Socket {

errorRef = this.onError(reason => {
this.log("transport", "error", reason)
if(primaryTransport && !established) {
if(primaryTransport && !established){
clearTimeout(this.fallbackTimer)
fallback(reason)
}
Expand Down
Loading

0 comments on commit be4eb9a

Please sign in to comment.