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

test: switch from jest to vitest #1406

Merged
merged 18 commits into from May 21, 2023
Merged

test: switch from jest to vitest #1406

merged 18 commits into from May 21, 2023

Conversation

wodeni
Copy link
Member

@wodeni wodeni commented May 18, 2023

Description

This PR switches our testing framework from jest to vitest, which is ESM-first and much faster.

Implementation strategy and design decisions

  • Vitest doesn't support imports without file extensions and only seems to work well with Node's ECMAScript module resolution, which we already use. Therefore, instead of relying on the bundler and testing framework to resolve the extensionless imports in core, we switched all imports in core to include the .js file extension.
  • Remove a lot of configuration since vitest requires a lot less of them compared to jest.
  • Ported tests in both core and edgeworth to vitest and they worked well locally. However, edgeworth's tests seemed to hang the CI. Since main only runs coverage on core anyway, this PR won't change the behavior of the test script.

Examples with steps to reproduce them

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have reviewed any generated registry diagram changes

Open questions

Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)

@github-actions
Copy link

github-actions bot commented May 18, 2023

± Registry diff

📊 Performance

Key

Note that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.

     0s   1s   2s   3s   4s   5s   6s   7s   8s   9s
     |    |    |    |    |    |    |    |    |    |
name ▝▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▞▀▀▀▀▀▀▀▀▀▀▀▀▚▄▄▄▄▄▄▄▄▄▖
      compilation labelling optimization rendering

Data

                                                          0s   1s   2s   3s   4s   5s   6s   7s
                                                          |    |    |    |    |    |    |    |
set-theory-domain/tree-venn                               ▝▀▚▚
set-theory-domain/tree-tree                               ▝▚▚
set-theory-domain/tree-venn-3d                            ▝▚▚
group-theory/quaternion-multiplication-table              ▝▀▀▚▞▖
group-theory/quaternion-cayley-graph                      ▝▀▚▚
atoms-and-bonds/wet-floor                                 ▝▀▞▀▖
atoms-and-bonds/one-water-molecule                        ▝▞▖
set-theory-domain/continuousmap                           ▝▚▚
linear-algebra-domain/two-vectors-perp                    ▝▚▚
molecules/nitricacid-lewis                                ▝▀▀▚▀▚
exterior-algebra/vector-wedge                             ▝▚▚
shape-spec/all-shapes                                     ▝▚▚▄▖
shape-spec/arrowheads                                     ▝▞▖
graph-domain/textbook/sec1/fig1                           ▝▀▀▀▞▖
graph-domain/textbook/sec1/fig2                           ▝▀▀▀▀▞▖
graph-domain/textbook/sec1/fig3                           ▝▀▀▀▀▚▚
graph-domain/textbook/sec1/fig4                           ▝▀▀▀▀▀▚▀▖
graph-domain/textbook/sec1/fig5                           ▝▀▀▀▀▀▀▞▀▚
graph-domain/textbook/sec1/fig6                           ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▞▀▀▀▀▀▀▀▀▚
graph-domain/textbook/sec1/fig7                           ▝▀▀▞▖
graph-domain/textbook/sec1/fig8a                          ▝▀▀▀▀▀▀▞▀▀▚
graph-domain/textbook/sec1/fig8b                          ▝▀▀▀▀▚▀▖
graph-domain/textbook/sec1/fig9                           ▝▀▀▀▚▚
graph-domain/textbook/sec1/fig10                          ▝▀▀▀▞▖
graph-domain/textbook/sec1/fig11                          ▝▀▀▀▀▀▀▞▖
graph-domain/textbook/sec1/fig12                          ▝▀▀▀▀▀▀▞▀▀▚
graph-domain/textbook/sec1/fig13                          ▝▀▀▀▀▞▖
graph-domain/textbook/sec2/fig3                           ▝▀▀▀▀▀▀▀▀▚▀▀▖
graph-domain/textbook/sec2/fig4                           ▝▀▀▀▀▀▀▞▀▖
graph-domain/textbook/sec2/fig5                           ▝▀▀▀▀▀▀▀▀▀▚▀▀▖
graph-domain/textbook/sec2/fig6                           ▝▀▀▀▀▀▀▀▀▀▀▀▞▀▀▚
graph-domain/textbook/sec2/fig9                           ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▚▀▀▀▖
graph-domain/textbook/sec2/fig10a                         ▝▀▀▀▞▀▖
graph-domain/textbook/sec2/fig10b                         ▝▀▀▀▞▖
graph-domain/textbook/sec2/fig11a                         ▝▀▚▚
graph-domain/textbook/sec2/fig11b                         ▝▀▚▚
graph-domain/textbook/sec2/fig11c                         ▝▀▀▞▖
graph-domain/textbook/sec2/fig12                          ▝▀▚▚
graph-domain/textbook/sec2/fig13                          ▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▞▀▀▀▀▀▀▀▀▀▀▀▀▀▖
graph-domain/textbook/sec2/fig14                          ▝▀▀▀▚▚
graph-domain/textbook/sec2/fig16b                         ▝▀▀▚▚
geometry-domain/textbook_problems/c05p13                  ▝▀▚▚
geometry-domain/textbook_problems/c01p01                  ▝▀▚▚
geometry-domain/textbook_problems/c03p01                  ▝▀▚▚
geometry-domain/textbook_problems/c05p01                  ▝▀▚▚
geometry-domain/textbook_problems/ex                      ▝▀▀▚▚
triangle-mesh-3d/two-triangles                            ▝▚▚
random-sampling/test                                      ▝▀▀▀▚▚
geometry-domain/textbook_problems/c11p12                  ▝▀▚▚
word-cloud/example                                        ▝▀▞▖
geometry-domain/siggraph-teaser                           ▝▀▚▚
minkowski-tests/maze/non-convex                           ▝▀▞▖
lagrange-bases/lagrange-bases                             ▝▚▚
hypergraph/hypergraph                                     ▝▀▀▀▞▀▀▀▀▀▀▀▀▚
persistent-homology/persistent-homology                   ▝▀▀▚▀▀▀▀▀▀▀▀▚▖
walk-on-spheres/laplace-estimator                         ▝▀▚▚
walk-on-spheres/poisson-estimator                         ▝▀▚▀▖
walk-on-spheres/nested-estimator                          ▝▀▀▀▞▀▚
walk-on-spheres/offcenter-estimator                       ▝▀▚▀▖
shape-distance/points-around-star                         ▝▀▀▀▞▖
shape-distance/points-around-polyline                     ▝▀▀▞▖
shape-distance/points-around-line                         ▝▀▞▖
shape-distance/lines-around-rect                          ▝▚▚
closest-point/test                                        ▝▀▀▀▀▀▀▞▖
fake-3d-linear-algebra/projection                         ▝▞▖
animation/center-shrink-circle                            ▝▞▖
structural-formula/molecules/caffeine                     ▝▀▀▚▚
mobius/mobius                                             ▝▞▖
molecules/glutamine                                       ▝▀▚▚
matrix-ops/tests/matrix-matrix-addition                   ▝▚▚
matrix-ops/tests/matrix-matrix-division-elementwise       ▝▚▚
matrix-ops/tests/matrix-matrix-multiplication-elementwise ▝▚▚
matrix-ops/tests/matrix-matrix-multiplication             ▝▚▚
matrix-ops/tests/matrix-matrix-subtraction                ▝▚▚
matrix-ops/tests/matrix-transpose                         ▝▚▚
matrix-ops/tests/matrix-vector-left-multiplication        ▝▚▚
matrix-ops/tests/matrix-vector-right-multiplication       ▝▚▚
matrix-ops/tests/scalar-vector-division                   ▝▚▚
matrix-ops/tests/scalar-vector-left-multiplication        ▝▚▚
matrix-ops/tests/scalar-vector-right-multiplication       ▝▚▚
matrix-ops/tests/vector-vector-addition                   ▝▚▚
matrix-ops/tests/vector-vector-division-elementwise       ▝▚▚
matrix-ops/tests/vector-vector-multiplication-elementwise ▝▚▚
matrix-ops/tests/vector-vector-outerproduct               ▝▚▚
matrix-ops/tests/vector-vector-subtraction                ▝▚▚
logic-circuit-domain/half-adder                           ▝▀▞▖
curve-examples/cubic-bezier                               ▝▀▞▀▖
triangle-mesh-2d/diagrams/cotan-formula                   ▝▀▚▚
triangle-mesh-2d/diagrams/concyclic-pair                  ▝▀▞▖
triangle-mesh-2d/diagrams/halfedge-mesh                   ▝▀▞▖
triangle-mesh-2d/diagrams/relative-orientation            ▝▀▞▖
triangle-mesh-2d/diagrams/triangle-centers                ▝▀▞▖
triangle-mesh-2d/diagrams/angle-equivalence               ▝▀▀▀▞▀▚
graph-domain/textbook/sec5/ex32                           ▝▀▀▀▀▀▚▀▀▀▀▀▖
curve-examples/open-elastic-curve                         ▝▀▚▀▖
curve-examples/closed-elastic-curve                       ▝▀▀▞▀▖
graph-domain/other-examples/arpanet                       ▝▀▀▀▀▀▀▀▀▀▀▞▀▀▀▀▀▀▚
graph-domain/other-examples/nyc-subway                    ▝▀▀▀▀▀▀▀▞▀▀▀▖
curve-examples/blobs                                      ▝▀▀▀▀▀▀▀▀▀▚▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▖

@cloudflare-pages
Copy link

cloudflare-pages bot commented May 18, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: fa3a10f
Status: ✅  Deploy successful!
Preview URL: https://073fd686.penrose-72l.pages.dev
Branch Preview URL: https://vitest.penrose-72l.pages.dev

View logs

@wodeni wodeni requested a review from samestep May 18, 2023 23:02
@wodeni wodeni self-assigned this May 19, 2023
@samestep
Copy link
Collaborator

I'm probably misremembering; did you say there's a lint that allows us to enforce the .js prefix in imports?

@wodeni
Copy link
Member Author

wodeni commented May 19, 2023

I'm probably misremembering; did you say there's a lint that allows us to enforce the .js prefix in imports?

Yeah https://github.com/mysticatea/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md

Copy link
Collaborator

@samestep samestep left a comment

Choose a reason for hiding this comment

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

Thanks for doing this Nimo! I'm cool with merging this PR under the following caveats:

  • see the minor comment I left above about codecov.yml
  • we should open an issue about actually running Edgeworth tests in CI
  • we should open an issue about the canvas warnings in Edgeworth tests
  • we should open an issue about switching from "moduleResolution": "node" to "moduleResolution": "node16" in optimizer, components, edgeworth, and editor

@samestep
Copy link
Collaborator

I'm probably misremembering; did you say there's a lint that allows us to enforce the .js prefix in imports?

Yeah https://github.com/mysticatea/eslint-plugin-node/blob/HEAD/docs/rules/file-extension-in-import.md

I no longer think we need to bother adding such a lint, because this is automatically enforced by TypeScript when we set "moduleResolution": "node16".

@wodeni
Copy link
Member Author

wodeni commented May 21, 2023

  • we should open an issue about actually running Edgeworth tests in CI

#1415

  • we should open an issue about the canvas warnings in Edgeworth tests

#1416

  • we should open an issue about switching from "moduleResolution": "node" to "moduleResolution": "node16" in optimizer, components, edgeworth, and editor

#1417

@wodeni wodeni merged commit 8ef8c77 into main May 21, 2023
10 checks passed
@wodeni wodeni deleted the vitest branch May 21, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants