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

Convert to bun:test for our tests, remove codecov #2149

Merged
merged 74 commits into from
Apr 4, 2024

Conversation

coolsoftwaretyler
Copy link
Collaborator

@coolsoftwaretyler coolsoftwaretyler commented Feb 23, 2024

What does this PR do and why?

This PR will convert our Jest test to bun test. This offers us a few advantages:

  1. Huge improvement in speed (locally, I see ~2-3x improvement)
  2. Native support for TypeScript, so no need for ts-jest
  3. Without the need for ts-jest and jest itself, we reduce our devDependencies as well
  4. Since we have moved over to Bun for dependency management and script running, this makes our development tooling more consistent overall.
  5. This also removes codecov, partially because we didn't take the time to implement it with Bun, but also because that package is deprecated, and I don't think our token has been working for some time. We discussed this in the maintainer chat and agreed.
  6. Fixes a missing MstError from a rebase

Steps to validate locally

  1. Make sure you have latest Bun installed
  2. Pull down this branch
  3. Run bun install
  4. Then run bun test:all - tests should pass.
  5. If you time it with time bun test:all, you can measure its runtime. Here's what I got on my 2020 Macbook Pro with Intel i7/32 GB RAM:
bun test:all  14.55s user 6.84s system 100% cpu 21.302 total

Compare this to the yarn test:all run in master, which reports:

Ran all test suites.
✨  Done in 75.39s.

Ran it with time yarn test:all and got slightly better results but with a lot more CPU usage:

yarn test:all  178.77s user 24.75s system 432% cpu 47.026 total

@coolsoftwaretyler coolsoftwaretyler marked this pull request as draft February 23, 2024 02:37
@coolsoftwaretyler
Copy link
Collaborator Author

I was able to get this working with a little bit of bash scripting. I don't love it, but since the Bun test runner doesn't behave precisely like jest -i, someone recommended this command instead, which we can chain together to get full tests running with minimal skips and changes.

The major downside right now is that coverage is no longer correctly generated. I will see if I can fix that up.

Bun also shipped support for expect.assertions, so I was able to keep that expectation in there

@coolsoftwaretyler coolsoftwaretyler marked this pull request as ready for review April 3, 2024 15:30
@coolsoftwaretyler coolsoftwaretyler changed the title Draft: Test/convert to bun test module Convert to bun:test for our tests, remove codecov Apr 3, 2024
@coolsoftwaretyler
Copy link
Collaborator Author

I added the specific toThrow error messages back to those expectations, and then realized we weren't appropriately failing with the one-liner script to run all tests, so I put together separate bash scripts that will fail the process if we got any failures (and output the full results if so).

I also removed cross-env for now since we were only using it in those test commands, and we've swapped to bash scripts which presume a specific type of environment variable setting.

@coolsoftwaretyler coolsoftwaretyler merged commit 018d9bf into master Apr 4, 2024
1 check passed
@coolsoftwaretyler coolsoftwaretyler deleted the test/convert-to-bun-test-module branch April 4, 2024 16:49
coolsoftwaretyler added a commit that referenced this pull request Apr 17, 2024
* chore: include bun types for tests, fix ts config

* test: fix expected literal for bun runtime in test

* test: fix circular tests

* test: bump snapshot for bun testing

* test: fix Frozen to expect Bun errors rather than Node

* test: remove inline snapshot error assertions for bun

* chore: remove a comment

* test: bump reference-custom snapshots for Bun

* chore: remove unused import

* test: use toJSON to assert equality on proxy object

* test: migrate action tracking middleware2 test to bun

* test: update async test for bun test runner

* test: fix object-node test for bun test runner

* chore: remove Jest and related packages

* test: import bun:test, fix type errors

* test: import bun test

* test: import bun test helpers to array test

* test: add bun test imports to async test

* test: add bun test imports to boolean

* test: add bun test imports to boxes-store

* test: add bun imports, fix errors to custom-type test

* test: import bun test helpers, fix erros in date test

* test: add bun test imports to deprecated test

* test: add bun test imports to enum test, fix errors

* test: use bun test imports, fix errors in env test

* test: use bun test imports for frozen test

* test: import bun test, fix hooks

* test: import bun test utilities, fix errors in identifier

* test: use bun imports for jsonpatch test

* test: use bun test imports, fix errors in late test

* test: import bun test helpers to lazy

* test: import bun test helpers, fix errors in literal test

* test: use bun test imports, fix ts error in map test

* test: import bun test helpers, fix errors in model test

* test: use bun test imports for name test

* test: import bun test helpers to node test, fix issues

* test: import bun test helpers, fix issues in number test

* test: add bun test helpers and fix ts issues in object test

* test: use bun test imports in optimizations test

* test: import bun test helpers, fix ts issues with optional extension

* test: import bun test utilities to optional test

* test: import bun test utiltities to parent properties

* test: import bun test utilties to pointer

* test: ipmort bun test helpers to primitives

* test: import bun test helpers to protect test

* test: add bun test imports for recordPatches

* test: import bun test utilities to reference-custom

* test: use bun test utilities, fix undefined issues

* test: use bun test helpers in reference test

* test: use bun test utilities in refinement test

* test: use bun test helpers for reflection test

* test: use bun test utilities in snapshotProcessor

* test: import bun test utilities and fix tyeps for string test

* test: use bun test helpers in this test

* test: use bun test utilities, fix ts error in type system test

* test: use bun test helpers, fix ts errors

* test: add bun test helpers to volatile test

* test: core tests work with skips

* test: skip perf tests temporarily

* test: simplify package.json testing scripts for bun

* chore: simplify bun testing in CI

* chore: remove codecov step for now

* spike: add a utility to reset action id for tests - should think about this more

* test: fix ~100 skipped tests

* test: narrow down to one problematic test in model

* test: only skip 47 tests now

* spike: try runnig all tests on their own, almost works

* test: get bun test:all to work

* test: no mor eneed for resetActionId

* test: bring back expect.assertions

* test: remove codecov

* fix: missing fail declaration

* test: add back specific error message tests

* test: ensure bun tests scripts exit when failing
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.

1 participant