Jest test files should be JavaScript only
INFO
This document represents an architecture decision record (ADR) and has been mirrored from the ADR section in our Shopware 6 repository. You can find the original version here
Context
There is a mix of both JavaScript and TypeScript Jest test files in the Administration. Respectively *.spec.js and *.spec.ts files. We want to settle on one format, to keep it uniform.
Current distribution
There are 46 *.spec.ts and 620 *.spec.js files.
Known problems with TypeScript Jest test files
- The TypeScript eslint
no-unused-varsrule is broken in Jest test files - There is no type safety for components, because
vue-test-utilswill just type toanyVue component - Several editors loose the Jest context for
*.spec.tsfiles - The Jest config only adds globals to
*.spec.jsfiles - TypeScript linting was disabled for
*.spec.tsfiles, therefore they are more like*.spec.jsfiles
Decision
Accounting the current distribution and the known problems we face with *.spec.ts files, we decided to use *.spec.js files from now on.
Consequences
All existing *.spec.ts where moved to *.spec.js files and TypeScript specific code was removed. Additionally to prevent new *.spec.ts files an eslint rule was added which prevents new files to be added.