Page MenuHomePhabricator

[Cashtab] Update jest
ClosedPublic

Authored by bytesofman on Jan 5 2024, 13:41.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa797211d8923: [Cashtab] Update jest
Summary

Upgrade to jest 29

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
better-jest-tests
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26170
Build 51912: Build Diffcashtab-tests
Build 51911: arc lint + arc unit

Event Timeline

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: jest-watch-typeahead@1.1.0
npm ERR! Found: jest@29.7.0
npm ERR! node_modules/jest
npm ERR!   jest@"^29.7.0" from the root project
npm ERR!   peer jest@">= 25" from jest-when@3.5.2
npm ERR!   node_modules/jest-when
npm ERR!     dev jest-when@"^3.5.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR! node_modules/jest-watch-typeahead
npm ERR!   jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: jest@28.1.3
npm ERR! node_modules/jest
npm ERR!   peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR!   node_modules/jest-watch-typeahead
npm ERR!     jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-01-05T13_42_44_255Z-debug-0.log
Build cashtab-tests failed with exit code 1

delete unused transform files, move jest to dev dependency, back out un-needed styled component syntax changes

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: jest-watch-typeahead@1.1.0
npm ERR! Found: jest@29.7.0
npm ERR! node_modules/jest
npm ERR!   dev jest@"^29.7.0" from the root project
npm ERR!   peer jest@">= 25" from jest-when@3.5.2
npm ERR!   node_modules/jest-when
npm ERR!     dev jest-when@"^3.5.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR! node_modules/jest-watch-typeahead
npm ERR!   jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: jest@28.1.3
npm ERR! node_modules/jest
npm ERR!   peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR!   node_modules/jest-watch-typeahead
npm ERR!     jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-01-05T13_48_20_217Z-debug-0.log
Build cashtab-tests failed with exit code 1

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: jest-watch-typeahead@1.1.0
npm ERR! Found: jest@29.7.0
npm ERR! node_modules/jest
npm ERR!   dev jest@"^29.7.0" from the root project
npm ERR!   peer jest@">= 25" from jest-when@3.6.0
npm ERR!   node_modules/jest-when
npm ERR!     dev jest-when@"^3.6.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR! node_modules/jest-watch-typeahead
npm ERR!   jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: jest@28.1.3
npm ERR! node_modules/jest
npm ERR!   peer jest@"^27.0.0 || ^28.0.0" from jest-watch-typeahead@1.1.0
npm ERR!   node_modules/jest-watch-typeahead
npm ERR!     jest-watch-typeahead@"^1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-01-05T13_54_56_391Z-debug-0.log
Build cashtab-tests failed with exit code 1

update deps to fix npm i conflicts

Tail of the build log:

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/list.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/list.js.map'

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/nft1.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/nft1.js.map'

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/utils.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/utils.js.map'

Failed to parse source map from '/work/cashtab/node_modules/react-image/umd/index.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/react-image/umd/index.js.map'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/index.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/index.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/nft1.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/nft1.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/tokentype1.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/tokentype1.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/util.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/util.ts'

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  821.44 kB  build/static/js/main.2c10d7bf.js
  68.09 kB   build/static/css/main.411829bd.css

The bundle size is significantly larger than recommended.
Consider reducing it with code splitting: https://goo.gl/9VhYWB
You can also analyze the project dependencies: https://goo.gl/LeUzfb

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment


> cashtab@1.0.0 test
> node scripts/test.js --reporters=default --reporters=jest-junit --coverageReporters=text --coverageReporters=lcov --coverageReporters=teamcity

Error: Could not resolve a module for a custom reporter.
  Module name: jest-junit
    at /work/cashtab/node_modules/jest-config/build/normalize.js:426:15
    at Array.map (<anonymous>)
    at normalizeReporters (/work/cashtab/node_modules/jest-config/build/normalize.js:409:20)
    at /work/cashtab/node_modules/jest-config/build/normalize.js:747:17
    at Array.reduce (<anonymous>)
    at normalize (/work/cashtab/node_modules/jest-config/build/normalize.js:608:14)
    at readConfig (/work/cashtab/node_modules/jest-config/build/index.js:160:74)
    at async readConfigs (/work/cashtab/node_modules/jest-config/build/index.js:424:26)
    at async runCLI (/work/cashtab/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/work/cashtab/node_modules/jest-cli/build/run.js:130:37)
mv: cannot stat 'test': No such file or directory
Build cashtab-tests failed with exit code 1

Tail of the build log:

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/list.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/list.js.map'

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/nft1.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/nft1.js.map'

Failed to parse source map from '/work/cashtab/node_modules/etoken-list/dist/utils.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/etoken-list/dist/utils.js.map'

Failed to parse source map from '/work/cashtab/node_modules/react-image/umd/index.js.map' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/react-image/umd/index.js.map'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/index.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/index.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/nft1.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/nft1.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/tokentype1.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/tokentype1.ts'

Failed to parse source map from '/work/cashtab/node_modules/slp-mdm/lib/util.ts' file: Error: ENOENT: no such file or directory, open '/work/cashtab/node_modules/slp-mdm/lib/util.ts'

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  821.44 kB  build/static/js/main.2c10d7bf.js
  68.09 kB   build/static/css/main.411829bd.css

The bundle size is significantly larger than recommended.
Consider reducing it with code splitting: https://goo.gl/9VhYWB
You can also analyze the project dependencies: https://goo.gl/LeUzfb

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment


> cashtab@1.0.0 test
> node scripts/test.js --reporters=default --reporters=jest-junit --coverageReporters=text --coverageReporters=lcov --coverageReporters=teamcity

Error: Could not resolve a module for a custom reporter.
  Module name: jest-junit
    at /work/cashtab/node_modules/jest-config/build/normalize.js:426:15
    at Array.map (<anonymous>)
    at normalizeReporters (/work/cashtab/node_modules/jest-config/build/normalize.js:409:20)
    at /work/cashtab/node_modules/jest-config/build/normalize.js:747:17
    at Array.reduce (<anonymous>)
    at normalize (/work/cashtab/node_modules/jest-config/build/normalize.js:608:14)
    at readConfig (/work/cashtab/node_modules/jest-config/build/index.js:160:74)
    at async readConfigs (/work/cashtab/node_modules/jest-config/build/index.js:424:26)
    at async runCLI (/work/cashtab/node_modules/@jest/core/build/cli/index.js:151:59)
    at async Object.run (/work/cashtab/node_modules/jest-cli/build/run.js:130:37)
mv: cannot stat 'test': No such file or directory
Build cashtab-tests failed with exit code 1
cashtab/src/hooks/__tests__/useWallet.test.js
33 โ†—(On Diff #43930)

While it is bad practice to simply delete a test because it's failing, the upgrade to jest29 revealed that these tests are not doing anything, and I am not at all sure why they were passing before.

Diving into the tests, we actually need a lot more to support this kind of automatic integration test.

  • A mock for localforage
  • Different react testing libraries

Have worked on adding these to Cashtab in the past. Jest on a large webpack app is prone to raising hard-to-troubleshoot errors.

Upgrading to the latest (supported) jest is step 1 toward getting automatic integration tests.

69 โ†—(On Diff #43930)

the function doesn't actually change wallet. It changes walletRefreshInterval, but this is unavailable in result.current

cashtab/src/components/Common/__tests__/QRCode.test.js
30 โ†—(On Diff #43931)

in jest 29, need to accept a mock function here

testing that setTimeout has been called (which is called in the same block as OnClick) is redundant, the click method is what we want to test

bytesofman published this revision for review.Jan 5 2024, 14:12
bytesofman added inline comments.
cashtab/src/hooks/__tests__/useWallet.test.js
33 โ†—(On Diff #43931)

see inline comments explaining removal of these faulty tests earlier in draft history

Fabien requested changes to this revision.Jan 5 2024, 20:22
Fabien added a subscriber: Fabien.
Fabien added inline comments.
cashtab/src/components/Home/__tests__/__snapshots__/Home.test.js.snap
20 โ†—(On Diff #43931)

How is that related to jest update ?

cashtab/src/hooks/__tests__/useWallet.test.js
33 โ†—(On Diff #43931)

According to this previous comment this can be removed in its own diff

This revision now requires changes to proceed.Jan 5 2024, 20:22
bytesofman added inline comments.
cashtab/src/components/Home/__tests__/__snapshots__/Home.test.js.snap
20 โ†—(On Diff #43931)

This is an artifact of following react-svg recommend svg mock for snapshots to work.

See https://react-svgr.com/docs/jest/

Tested with 'svg' instead of 'div' and this works, so using this.

cashtab/src/hooks/__tests__/useWallet.test.js
33 โ†—(On Diff #43931)
bytesofman marked an inline comment as done.

snapshot update to svg

to be rebased on D15104

This revision is now accepted and ready to land.Jan 8 2024, 19:53
This revision was automatically updated to reflect the committed changes.