Description
Topic
Hey there,
in order to push the state of the esm build forward I'd suggest to add some kind of integration tests. The main issue I'm trying to tackle is to be able to check correct type declarations. At a later stage one could also add separate tests for each addon/build which is defined in the exports
field of the package.json. Beyond that one could test the global or instance mode in other frameworks such as react or vuejs if neccessary.
To be more specific I'm thinking of running a child process like tsc --noEmit
within a test folder/project with different compiler options and setups (unless there are better options).
├── test
│ ├── integrations
│ │ ├── typescript
│ │ │ ├── package.json
│ │ │ ├── index.ts
│ │ │ └── tsconfig.json
│ │ ├── react
│ │ └── vuejs
│ ├── unit
│ └── visual
├── package.json
└── <root>
// ./test/integrations/typescript/package.json
{
"name": "ts-test",
"scripts": {
"test": "tsc --noEmit",
},
"devDependencies": {
"p5": "file:../../../dist/app.js",
"typescript": "^5.0.0"
}
}
// ./test/integrations/typescript/index.ts
import p5 from 'p5';
new p5((p) =>{
p.setup = () => {
// ...
}
})
import { execSync } from 'node:child_process';
process.chdir('<root>/test/integration/typescript');
execSync('npm i');
execSync('npm run test');
I'd recommend to run such tests only locally and not integrate them to the CI.
Another approach would be to use a library like mockFs or fs-fixture. They programmatically create test files in a temp folder and delete them afterwards.
The general benefit would be a streamlined test experience.
A prerequisite would be to migrate to esm completely in order to settle the issues mentioned in #7863
Any of this is open for discussion.