Skip to content

Conversation

@fregante
Copy link
Member

@fregante fregante commented Jul 8, 2022

For speed and lack of hacks everywhere. The API may be less great.

I used Jest’ codemods to do most of the changes and then fixed a couple of AVA-only features/awkwardness

Edit: I reverted the codemod and did a simple search and replace to preserve the assert-style tests; Jest prefers expect(), which doesn't support custom error messages

Before

❯ nr ava

(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52859) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
  ✔ source › helpers › is-low-quality-comment › isLowQualityComment
  ✔ source › github-helpers › search-query › .get
  ✔ source › github-helpers › search-query › .getQueryParts
  ✔ source › github-helpers › search-query › getQueryParts with spaces support
  ✔ source › github-helpers › search-query › .set
  ✔ source › github-helpers › search-query › .edit
  ✔ source › github-helpers › search-query › .replace
  ✔ source › github-helpers › search-query › .remove
  ✔ source › github-helpers › search-query › .add
  ✔ source › github-helpers › search-query › .includes
  ✔ source › github-helpers › search-query › defaults
  ✔ source › github-helpers › search-query › deduplicate is:pr/issue
  ✔ source › github-helpers › search-query › remove additional spaces
  ✔ source › github-helpers › search-query › parse label link
  ✔ source › helpers › get-items-between › getItemsBetween
  ✔ source › helpers › loose-parse-int › looseParseInt
  ✔ source › github-helpers › parse-backticks › parseBackticks
  ✔ source › helpers › pluralize › pluralize
  ✔ source › helpers › select-has › basic :has() support (144ms)
  ✔ source › helpers › select-has › returns undefined if not found
  ✔ source › helpers › select-has › supports looking for descendants in base element
  ✔ source › helpers › select-has › supports looking for direct children in base element
  ✔ source › helpers › select-has › throws error when there’s a space before :has()
  ✔ source › helpers › select-has › throws error when there is more than one :has()
  ✔ source › helpers › select-has › throws on sibling selectors
  ✔ test › shorten-link › shorten link in comment text
  ✔ test › shorten-link › avoid shortening link in code block inside comment
  ✔ test › shorten-link › avoid shortening link in embedded file preview inside comment
  ✔ test › shorten-link › shorten link in review comment text
  ✔ test › shorten-link › avoid shortening links in suggestion inside review comment
  ✔ source › github-helpers › prevent-link-loss › preventPrCommitLinkLoss
  ✔ source › github-helpers › prevent-link-loss › preventPrCompareLinkLoss
  ✔ source › github-helpers › prevent-link-loss › preventDiscussionLinkLoss
  ✔ source › github-helpers › github-url › branch
  ✔ source › github-helpers › github-url › branch with multiple slashes
  ✔ source › github-helpers › github-url › object
  ✔ source › github-helpers › github-url › nested object
  ✔ source › github-helpers › github-url › change branch
  ✔ source › github-helpers › github-url › change filePath
  ✔ source › github-helpers › github-url › get filePath from search
  ✔ test › get-current-committish › getCurrentCommittish
  ✔ source › helpers › show-whitespace-on-line › showWhiteSpacesOnLine raw (358ms)
  ✔ source › helpers › show-whitespace-on-line › showWhiteSpacesOnLine real code (321ms)
  ✔ source › helpers › show-whitespace-on-line › showWhiteSpacesOnLine highlighted code (311ms)
  ✔ source › github-helpers › index › getConversationNumber (122ms)
  ✔ source › github-helpers › index › parseTag (105ms)
  ✔ source › github-helpers › index › compareNames
  ✔ source › github-helpers › index › getLatestVersionTag
  ✔ source › github-helpers › index › shouldFeatureRun
  ✔ source › github-helpers › index › addHotkey if one is specified
  ✔ source › github-helpers › index › addHotkey if the same is already specified
  ✔ source › github-helpers › index › addHotkey when none are specified
  ─

  52 tests passed

Screen Shot 11

After

❯ npx vitest run

 RUN  v0.17.1 refined-github

 ✓ source/github-helpers/search-query.test.ts (13)
 ✓ source/helpers/select-has.test.ts (7)
 ✓ source/helpers/get-items-between.test.ts (1)
 ✓ source/helpers/loose-parse-int.test.ts (1)
 ✓ source/helpers/is-low-quality-comment.test.ts (1)
 ✓ source/helpers/pluralize.test.ts (1)
 ✓ source/github-helpers/parse-backticks.test.ts (1)
 ✓ source/helpers/show-whitespace-on-line.test.ts (3)
 ✓ source/github-helpers/github-url.test.ts (7)
 ✓ test/get-current-committish.test.ts (1)
 ✓ test/shorten-link.test.ts (5)
 ✓ source/github-helpers/index.test.ts (8)
 ✓ source/github-helpers/prevent-link-loss.test.ts (3)

Test Files  13 passed (13)
     Tests  52 passed (52)
      Time  2.28s (in thread 654ms, 349.02%)

Screen Shot 10

@fregante fregante changed the title AVA -> Vitest 😟 Meta: AVA -> Vitest Jul 8, 2022
@fregante fregante added the meta Related to Refined GitHub itself label Jul 8, 2022
'r2.0',
'3.0',
]), '3.0', 'Tags should be sorted by version');
])).toBe('3.0');
Copy link
Member Author

Choose a reason for hiding this comment

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

The only problem is this. Jest and vitest don’t have this sort of message, so the only way to support it would be to move the message to a comment. Not that great of a DX

The closes equivalent would be to wrap each expectation in an test() to describe it and then replace the parent test() with describe()

Copy link
Member Author

Choose a reason for hiding this comment

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

The assert api might match AVA’s exactly https://www.chaijs.com/api/assert/, and it's also included in 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.

Fixed!

@@ -0,0 +1,68 @@
// Vitest Snapshot v1

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 have to mark this file as generated in .gitattributes

@yakov116
Copy link
Member

yakov116 commented Jul 8, 2022

Is it a federal crime to drop a sindre package?

@fregante
Copy link
Member Author

fregante commented Jul 8, 2022

Is it a federal crime to drop a sindre package?

Shh don't tell him, he's AFK

@fregante
Copy link
Member Author

fregante commented Jul 8, 2022

I haven't even finished work on the drop-xo branch yet

@fregante fregante marked this pull request as ready for review July 9, 2022 07:39
@fregante fregante merged commit 05d9fc0 into main Jul 9, 2022
@fregante fregante deleted the vitest branch July 9, 2022 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants