prismicio / prismic-next

Helpers to integrate Prismic into Next.js apps
https://prismic.io/docs/technologies/nextjs
Apache License 2.0
57 stars 7 forks source link

test: use Vitest #19

Closed angeloashmore closed 2 years ago

angeloashmore commented 2 years ago

Types of changes

Description

This PR replaces tests written with AVA with test written with Vitest.

The change was done to simplify the test code and allow for easy mocking of next/router. This will be needed to support and test basePath support.

Checklist:

✌️

codecov-commenter commented 2 years ago

Codecov Report

Merging #19 (cb57c55) into main (c3841e2) will increase coverage by 22.72%. The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             main       #19       +/-   ##
============================================
+ Coverage   77.27%   100.00%   +22.72%     
============================================
  Files           8         8               
  Lines         110       541      +431     
  Branches       21        22        +1     
============================================
+ Hits           85       541      +456     
+ Misses         18         0       -18     
+ Partials        7         0        -7     
Impacted Files Coverage Δ
src/PrismicPreview.tsx 100.00% <100.00%> (+40.00%) :arrow_up:
src/exitPreview.ts 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)
src/lib/getCookie.ts 100.00% <100.00%> (ø)
src/redirectToPreviewURL.ts 100.00% <100.00%> (+20.00%) :arrow_up:
src/setPreviewData.ts 100.00% <0.00%> (+20.00%) :arrow_up:
src/enableAutoPreviews.ts 100.00% <0.00%> (+20.00%) :arrow_up:
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c3841e2...cb57c55. Read the comment docs.

github-actions[bot] commented 2 years ago

size-limit report 📦

Path Size
dist/index.js 2.39 KB (-0.65% 🔽)
./dist/index.cjs 7.14 KB (-0.37% 🔽)
lihbr commented 2 years ago

Overall I think this is the way we want to move on with our test framework (migrating from AVA to Vitest on all SDKs) 🙌

angeloashmore commented 2 years ago

Yes, I agree. I like AVA over Jest because Jest has/had issues handling ESM, TypeScript, and using modern bundlers like esbuild. AVA works well for that, but Vitest is even better. Jest API w/ modern underpinnings… it's great!

I'll submit a PR to the TypeScript template do we can make a decision.