Conversation
|
Also pinging @stefangehn, @blatinier and @Lucas-C here. Let me know if you find this useful and please share tips/improvements/general ideas. I'd love for someone more knowledgeable than me to write some proper tests and I hope this is a good starting-off point. A way to simply have some |
| "build-prod": "webpack --config isso/js/webpack.config.js --merge --config-name dev --config-name prod" | ||
| }, | ||
| "devDependencies": { | ||
| "jest": "^27.5.0", |
There was a problem hiding this comment.
"jest-puppeteer" is missing ;)
There was a problem hiding this comment.
Adding jest-puppeteer to devDependencies will automatically pull in a 400Mb+ download of headless chrome, as explained earlier. That's why I'm a bit hesitant to add it here.
Imo it should be up to the user whether they need to run the end-to-end tests.
Maybe there's an option to configure the package before installing to not pull in the chrome download automatically?
| @@ -0,0 +1,6 @@ | |||
| module.exports = { | |||
There was a problem hiding this comment.
This file should be at the root of the repository.
It is currently ignored by Jest when running npm test
There was a problem hiding this comment.
I'd like to keep all javascript-related stuff inside isso/js/, so I'll have to figure out a way for Jest to read this file.
See https://github.com/smooth-code/jest-puppeteer#configure-puppeteer
(remains TODO)
There was a problem hiding this comment.
Point of reference: argos-ci/jest-puppeteer#160 (comment)
process.env.JEST_PUPPETEER_CONFIG = require.resolve('./jest-puppeteer.config.js');|
Hey @Lucas-C, thank you so much for reviewing and verifying! I probably should have split this PR into two PRs, one for Jest and one for the addition of Re: Instrumentation is hard, and I'm open to suggestions here as I have no experience and no idea what accepted standard practices are. |
fe23d2c to
fbaac0b
Compare
Provide a base config and npm commands to run unit tests using the `Jest` tool. Recommendations have been lifted from https://mailchimp.com/developer/open-commerce/docs/testing-requirements/ `jsdom` "emulates" a browser environment in a light way so that access to `window`, `document` etc. is possible.
Just a simple test as a starting point for further ones.
Test expected languages when none are set in the browser. Could be expanded further.
As discussed in #754, add some basic Jest testing config and examples to facilitate finally writing some frontend code tests.
Note: End-to-end tests using
puppeteerwere split off and moved into #807Terminology
Running
Install the needed packages:
Then run:
npm run test-unitfor Jest unit testsHighly WIP at the moment, but could be useful to someone else working on the same issues. Please communicate and collaborate!
Depends on #800.
I have temporarily changed the base to that branch to make it easier to review this change.