RealDevSquad / RealDevSquad/website-backend
[RFC] Testing in a new repo with TS and JS.
@MehulKChaudhari is already working on this.
Since Sep 9, 2022.
- Dominant language
- JavaScript
- Stars
- 74
- Forks
- 276
- Avg merge
- 1d 26m
- Merged PRs (30d)
- 14
Description
Testing for new repo which will have both TS and JS code.
Now we get an error as Mocha couldn't understand the ESM imports. And till now we couldn't find any mocha plugin which can help us test JS and TS files.
Strategy 1: Build and test.
In this, we will first build our whole backend and then test the whole backend with the existing testing setup. And this will work totally fine because TS will be converted to JS upon building and after conversion, Mocha can test it easily. And later when the whole repo is migrated to TS we will add ts-mocha or a similar test runner to test normally.
Strategy 2: Add ts-mocha.
In this strategy, we will have both mocha and ts-mocha setups and we will be testing both the JS and TS files separately.
But it will give an error if any JS file has a dependency on TS.
Strategy 3: Start using Vitest.
( Vitest is just an option we can consider any good test runner which suits our case better)
In this Strategy, we will start migrating the test along with the code files simultaneously and test those files with Vitest and the JS code with mocha upon building but again we are not aware of caveats yet.
These are the options for now. Please comment if you know of any better strategies and improvements.
For now strategy 1 seems to be the best as we will not face any errors and we can focus on migrating code later after successful 100% migration of repo we will add a TS file test runner.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.