Skip to content

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

Merged
erunion merged 6 commits into
mainfrom
feat/move-tests-to-vitest
Aug 13, 2023
Merged

feat(test): moving unit testing over to vitest#789
erunion merged 6 commits into
mainfrom
feat/move-tests-to-vitest

Conversation

@erunion

@erunion erunion commented Aug 9, 2023

Copy link
Copy Markdown
Member

🧰 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
Copy Markdown
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

@llimllib llimllib left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no config! lovely

@kanadgupta kanadgupta left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread __tests__/__snapshots__/index.test.ts.snap
Comment thread package.json Outdated
Comment thread package.json
"prepack": "npm run build",
"prepare": "husky install",
"pretest": "npm run lint",
"prettier": "prettier --list-different \"./**/**.{js,ts,md}\"",

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
@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