Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 1.55 KB

2023-04-14-jest-test-files-should-be-javascript-only.md

File metadata and controls

34 lines (27 loc) · 1.55 KB
title date area tags
Jest test files should be JavaScript only
2023-04-14
admin
admin
jest
javascript
typescript

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-vars rule is broken in Jest test files
  • There is no type safety for components, because vue-test-utils will just type to any Vue component
  • Several editors loose the Jest context for *.spec.ts files
  • The Jest config only adds globals to *.spec.js files
  • TypeScript linting was disabled for *.spec.ts files, therefore they are more like *.spec.js files

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.