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 AVA test runner integration #1022

Merged
merged 2 commits into from Dec 7, 2022
Merged

Add AVA test runner integration #1022

merged 2 commits into from Dec 7, 2022

Conversation

david0xd
Copy link
Contributor

@david0xd david0xd commented Nov 30, 2022

This PR will add tools and configurations which will provide a new way of unit testing using AVA test runner which is primarily added because of testing SES functionalities.

Fixes: #1016

PR summary

Added packages

ava - AVA test runner.
@ava/typescript - TypeScript support for AVA test runner.
c8 - Test coverage reporter recommended for AVA, using v8.
mkdirp - Cross platform mkdir. Used to merge and regenerate coverage report.
nyc - Used to merge and regenerate coverage report.
shx - Cross platform solution for cp used when copying files is needed to merge coverage report.

Added yarn scripts

test:ava - This will run only AVA tests. This script is used in the main test script. It can be useful when working only on AVA tests or testing security (SES) related parts of code.
merge:coverage - This command will execute several scripts in order to merge coverage report and clean working directory from all temporary files and folders used in the process.

Modified yarn scripts

test - This script is now modified to run AVA first, then continue with usual Jest testing workflow. It is required for AVA to run first because Jest exits the process after it finishes with errors. After successful run, merge:coverage command is added to the end of this script.

Added configurations

New configuration file is added for the AVA tests - ava.config.js.
There is also a new file for configuring coverage test reporter for c8 - .c8rc.json.
AVA and Jest configurations are added/modified in order to run two separate group of tests in two independent runs of both test runners. AVA tests needs to have .ava.test.ts suffix and will be automatically picked up by the AVA test runner. Test with suffix .ava.test.ts will be ignored by Jest and excluded from coverage as well.

Additional notes

timeout.ava.test.ts file is added with single test that is testing small part of security. This is required because AVA test runner requires at least one test (file) in order to work properly with the configuration and yarn scripts.
Coverage report for AVA tests is generated under coverage-ava directory. This is temporary directory which is deleted in the coverage merge process. After both test runners have finished, coverage reports will be merged together and can be browser under regular coverage directory as usual.
No SES functionalities or configurations are added in this PR, as this is only to support future testing of it.

@codecov-commenter
Copy link

codecov-commenter commented Dec 1, 2022

Codecov Report

Merging #1022 (5c1d834) into main (7f5cfd4) will increase coverage by 0.17%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1022      +/-   ##
==========================================
+ Coverage   93.32%   93.50%   +0.17%     
==========================================
  Files          95       94       -1     
  Lines        9901     9882      -19     
  Branches      937      936       -1     
==========================================
  Hits         9240     9240              
+ Misses        661      642      -19     
Impacted Files Coverage Δ
...ages/snaps-execution-environments/src/globals.d.ts

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@david0xd david0xd marked this pull request as ready for review December 1, 2022 16:48
@david0xd david0xd requested a review from a team as a code owner December 1, 2022 16:48
@david0xd david0xd marked this pull request as draft December 1, 2022 19:13
@david0xd david0xd force-pushed the dd/ava-integration branch 4 times, most recently from b416ce1 to 695b1d0 Compare December 5, 2022 15:56
@david0xd david0xd marked this pull request as ready for review December 6, 2022 10:48
hmalik88
hmalik88 previously approved these changes Dec 6, 2022
Copy link
Contributor

@hmalik88 hmalik88 left a comment

Choose a reason for hiding this comment

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

LGTM.

Add some test refactoring

Revert jest.environment.js change

Fix ts-comment in test

Add coverage merge process

Fix build issues

Fix test snapshot errors

Fix broken test in snaps-utils

Fix problematic test snapshot

Fix dependencies after rebase

Try to fix problematic snapshots in rollback

Update test snapshot for webpack plugin (root test run)

Try to fix test snapshot on another platform (Ubuntu)

Fix snapshot
@david0xd david0xd merged commit 5788c03 into main Dec 7, 2022
@david0xd david0xd deleted the dd/ava-integration branch December 7, 2022 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate and configure AVA test runner into execution environments
4 participants