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

feat(test): moving unit testing over to vitest #789

Merged
merged 6 commits into from
Aug 13, 2023

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 9, 2023

🧰 Changes

Vitest is fast as hell and drops our unit test execution time down by a crazy amount.

Before

Test Suites: 21 passed, 21 total
Tests:       5 todo, 620 passed, 625 total
Snapshots:   27 passed, 27 total
Time:        2.836 s, estimated 4 s
Ran all test suites.
npx jest  22.41s user 1.97s system 737% cpu 3.306 total

Now

 Test Files  20 passed (20)
      Tests  619 passed | 5 todo (624)
   Start at  13:24:19
   Duration  1.33s (transform 1.70s, setup 1ms, collect 4.26s, tests 2.05s, environment 2ms, prepare 1.51s)

npx vitest run  6.87s user 1.66s system 485% cpu 1.755 total

@@ -1,5 +1,7 @@
import type { OASDocument } from '../../src/rmoas.types';

import { describe, beforeAll, it, expect } from 'vitest';
Copy link
Member Author

Choose a reason for hiding this comment

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

Vitest offers a globals option1 for automatically adding these methods to every unit test but I kind of prefer the explicitness of not doing that.

Footnotes

  1. https://vitest.dev/config/#globals

@erunion erunion added enhancement New feature or request refactor Issues about tackling technical debt labels Aug 9, 2023
Copy link
Contributor

@llimllib llimllib left a comment

Choose a reason for hiding this comment

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

no config! lovely

Copy link
Member

@kanadgupta kanadgupta left a comment

Choose a reason for hiding this comment

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

couple minor comments below but LGTM overall! absolutely obsessed with the fact that there's no config file

__tests__/__snapshots__/index.test.ts.snap Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
"lint:docs": "npx -y alex .",
"lint:types": "tsc --noEmit",
"prebuild": "rm -rf dist/",
"prepack": "npm run build",
"prepare": "husky install",
"pretest": "npm run lint",
"prettier": "prettier --list-different \"./**/**.{js,ts,md}\"",
Copy link
Member

Choose a reason for hiding this comment

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

doesn't have to happen in this PR but thoughts on running prettier against everything?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think this is already doing that? we don't have any yaml files in here for testing flows

Copy link
Member

Choose a reason for hiding this comment

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

looks like prettier is flagging a few other files:

CleanShot 2023-08-14 at 11 43 58@2x

erunion and others added 2 commits August 12, 2023 20:03
Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com>
@erunion erunion merged commit 190a6c7 into main Aug 13, 2023
7 checks passed
@erunion erunion deleted the feat/move-tests-to-vitest branch August 13, 2023 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor Issues about tackling technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants