Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jest test runner with 20% coverage minimum #209

Merged
merged 9 commits into from
Aug 24, 2022
Merged

Add Jest test runner with 20% coverage minimum #209

merged 9 commits into from
Aug 24, 2022

Conversation

akprasad
Copy link
Contributor

@akprasad akprasad commented Aug 23, 2022

To make our JavaScript code more robust, switch to CLI-based testing that runs as part of our usual deploys.

Test plan: ran the tests.

@@ -0,0 +1,61 @@
// Compiles JavaScript with esbuild.
//
// We use this because esbuild-jest hasn't been updated in two years.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to use ts-jest; it looks like ts-jest recently added support for esbuild as an experimental feature. Though I'm not clear if this support is working yet. See:

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts-jest does not support esbuild based transpilation
you could use swc-jest, we use at the company to run around 5k tests and it is pretty fast and awesome

Copy link
Contributor

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akprasad what did you mean by "Jest thinks everything being tested is one big file"? Can you send the coverage output you get (or perhaps change CI to print out coverage output to the console, instead of writing it out to a file)?

Copy link
Contributor

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akprasad what did you mean by "Jest thinks everything being tested is one big file"? Can you send the coverage output you get (or perhaps change CI to print out coverage output to the console, instead of writing it out to a file)?

package.json Show resolved Hide resolved
@akprasad
Copy link
Contributor Author

akprasad commented Aug 24, 2022

@akprasad what did you mean by "Jest thinks everything being tested is one big file"? Can you send the coverage output you get (or perhaps change CI to print out coverage output to the console, instead of writing it out to a file)?

I mean that Jest doesn't distinguish among different source files. The output has changed a little bit since I wrote that, but here's what we get now:

 PASS  test/js/reader.test.js
 PASS  test/js/dictionary.test.js
 PASS  test/js/proofer.test.js
 PASS  test/js/routes.test.js
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

with no indication of either total coverage or coverage per source file.

@akprasad akprasad changed the title [WIP] Jest testing Add Jest test runner with 20% coverage minimum Aug 24, 2022
@akprasad
Copy link
Contributor Author

I'm switching to Babel to unblock this. Tracking the esbuild work in #212.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants