chore: change to vitest and remove cjs bundling.
closes #1072, closes #1055
This is a change that is part of a bigger goal to improve our confidence in browser testing and update the codebase to adapt to node/browser environment without throwing errors:
- adds Vitest as the test framework that has browser testing.
- drops karma. eventually drop add-ins like Sinon used for mocking and completely build on Vitest.
- updates test imports to use Vitest API.
- adds browser testing for the packages.
- adds utility function to check the environment(node/browser) the code is running in.
- Fixes browser incompatible code in the codebase.
- Removes common js bundling tooling and support.
Status
- [x]
abstractionspackage is updated to vitest and has browser tests - [x]
authentication/azurepackage is updated to vitest and has a trigger for browser tests that pass - [x]
authentication/spfxis updated - [x]
httpis updated. - [x]
serialization/*is updated.
@baywet I'm having a blocker with completing this. When running the steps to build and test, there's an error with building that comes from having build instructions in tsconfig that outputs commonjs. I think it would be a good idea to make a decision on #1055 to unblock this. What do you think?
Agreed, let's get confirmation on the PM side. If Seb doesn't reply within a few days, please reach out to him directly
Hi @musale, Can you please give instructions on how to run the build and tests locally. this is what I get:
npm run build
npm run test
Hi @musale, Can you please give instructions on how to run the build and tests locally. this is what I get:
npm run build
npm run test
Hi @koros this CI/CD pipeline and build is adapted for a Linux environment. I see you're using PowerShell and this will fail for commands like clean and tsconfig file path resolutions. Please use WSL or a Linux environment to test this.
Hi @musale, Can you please give instructions on how to run the build and tests locally. this is what I get:
npm run build
npm run test
Hi @koros this CI/CD pipeline and build is adapted for a Linux environment. I see you're using PowerShell and this will fail for commands like
cleanandtsconfigfile path resolutions. Please use WSL or a Linux environment to test this.
@musale this seems to resolve the issue on Win OS
"build:@microsoft/*": "lerna run build --scope \"@microsoft/*\"",
"clean": "lerna run --parallel --stream --scope \"@microsoft/*\" clean",
"test:browser": "lerna run --scope \"@microsoft/*\" test:browser",
"test:node": "lerna run --scope \"@microsoft/*\" test:node",
See: https://github.com/magento/pwa-studio/issues/236#issuecomment-422485988

