aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/test (follow)
AgeCommit message (Collapse)AuthorFilesLines
2023-09-20Treat `undefined` value as empty in expect.toThrow (#5788)Gravatar LongYinan 1-3/+3
Fix: https://github.com/napi-rs/napi-rs/blob/main/examples/napi/__tests__/test.framework.js#L16-L19
2023-09-18feat(test): Implement `arrayContaining` (#5572)Gravatar WingLim 2-1/+53
* feat(test): implement `arrayContaining` * feat: early return when expectedArray is empty * feat: add test for toEqual * chore: use `JSC::isArray` * chore: use getIndex for performance * fix: use deepEqual --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-08-29Rename `uws_event_loop` to `event_loop_handle`Gravatar Jarred Sumner 1-1/+1
2023-08-28More renamingGravatar Jarred Sumner 1-1/+1
2023-08-28just kernel32 things (#4354)Gravatar Jarred Sumner 2-6/+5
* just kernel32 things * more * Update linux_c.zig * Update windows_c.zig * Add workaround Workaround https://github.com/ziglang/zig/issues/16980 * Rename http.zig to bun_dev_http_server.zig * Rename usages * more * more * more * thanks tigerbeetle * Rename `JSC.Node.Syscall` -> `bun.sys` * more * woops * more! * hmm * it says there are only 37 errors, but that's not true * populate argv * it says 32 errors! * 24 errors * fix regular build * 12 left! * Still 12 left! * more * 2 errors left... * 1 more error * Add link to Tigerbeetle * Fix the remainign error * Fix test timeout * Update syscall.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-24fix buildGravatar Dylan Conway 1-2/+2
2023-08-24update zig to 0.11.0 (#4233)Gravatar Jason 1-2/+2
* WIP * backup * more change * json related error sovled * number related issue solved * revert WriterType changed before * destroy -> free * jsonStringify related issues solved * fix mem.free expected []T or *[_]T, passed [*]const u8 * fix expected []T or *[_]T, passed [*:0]const u8 * fix build script * fix build script, for real * replace 0.11.0-dev.4006+bf827d0b5 to 0.12.0-dev.161+6a5463951 * fix build on macOS, COPYFILE.DATA -> COPYFILE_DATA * fix the last destroy on [*]ptr issue --------- Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-08-18Remove most C API usages, add debugger pretty printers for `Headers`, ↵Gravatar Jarred Sumner 1-18/+14
`URLSearchParams`, `FormData`, `Worker`, `EventTarget` (#4187) * Add pretty printers for `Headers`, `URLSearchParams`, and `FormData` * [untested] Add way to code generate getInternalProperties * bump * Bump Webkit * Ref the event loop while loaded * wip * checkpoint * another checkpoint * The code has been written * Fixup exports * Fix all the errors * Fix bug * [console.log] Fix bug when printing non-reified types missing values * Fix loading hash table * fix plugin * Fix ref & unref * auto-unref * various fixes * Update bun.zig * Set toStringTag * Delete code for macro JSX * Delete code for `bun dev` HTTP JS * Move Bun.serve to C++ API * Delete JSC C API code * :scissors: :skull: code * Use JSC C++ for `confirm`, `Crypto`, `prompt`, `alert` * more dead code * Update exports.zig * Use JSC C++ API for FFI * Remove remaining usages * Remove remaining usages * Update ffi.ts * Update InternalModuleRegistryConstants.h * draw the rest of the owl * Update webcore.zig * bind it * Fix performance regression in crypto.randomUIUD() * Update js_parser.zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-16Fix leaking .ptr (#4181)Gravatar Jarred Sumner 1-4/+4
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-10bun test: format description of test.each (#4092)Gravatar Jacques 1-8/+87
* bun test: format description * add tests for tests * only --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-08-08feat(bun:test) add support for test.each() and describe.each() (#4047)Gravatar Jacques 1-16/+235
* rename callback to func * update testscope to handle function arguments * works * big cleanup * works in debug, not release * fix memory issue & update tests * catch & str test * write types for each() & switch tests to ts * rm & typo * move some code around & support describe * review changes
2023-08-08feat(bun/test): Implement "toSatisfy" & "toIncludeRepeated" (fwup) (#3651)Gravatar Tiramify (A.K. Daniel) 2-0/+208
* Fix merge issues * oop * make codegen * Fix build issues --------- Co-authored-by: dave caruso <me@paperdave.net>
2023-08-06Code coverage for `bun test` (#3975)Gravatar Jarred Sumner 1-0/+1
* WIP code coverage initial commit * almost works * one approach * Code Coverage * Update WebKit * it works but is not yet accurate * skip double ascii check * wrapper * it works but i'm not sure what to do about blocks * hide blocks for now * Update ZigSourceProvider.cpp * Create coverage.md * Update nav.ts --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-08-06Implement --test-name-pattern (#3998)Gravatar dave caruso 2-2/+33
* Fix end not being emitted all the time * stuff * Implement -t * Undo js_printer changes * Undo http changes * Update InternalModuleRegistryConstants.h * Delete unrelated test --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-30Improv. (#3885)Gravatar Tiramify (A.K. Daniel) 1-13/+16
2023-07-28feat(bun/test): Impl. expect().pass() & expect().fail() (#3843)Gravatar Tiramify (A.K. Daniel) 2-0/+110
* Impl. pass & fail * fix * fix 2 * smol
2023-07-22[install] improve workspace substitution of npm dependencies (#3754)Gravatar Alex Lam S.L 1-1/+1
- respect semver ranges
2023-07-18[jest] execute lifecycle hooks on empty blocks (#3663)Gravatar Alex Lam S.L 1-8/+26
fixes #3494
2023-07-18zig upgrade (#3667)Gravatar Dylan Conway 4-33/+33
* upgrade * more fixes * Bump Zig --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-17Fix memory leak in `await new Response(latin1String).arrayBuffer()` and ↵Gravatar Jarred Sumner 1-2/+4
`await Response.json(obj).json()` (#3656) ❯ mem bun --smol response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 12.9 µs/iter (625 ns … 4.18 ms) 1 µs 567.17 µs 711.79 µs new Response().arrayBuffer() (new string each call, utf16) 12.85 µs/iter (1.67 µs … 1.56 ms) 2.17 µs 462.75 µs 621.13 µs new Response().arrayBuffer() (existing string, latin1) 6.53 µs/iter (6.21 µs … 7.07 µs) 6.64 µs 7.07 µs 7.07 µs Peak memory usage: 49 MB bun on  jarred/memory-leak-fix took 2s ❯ mem bun response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 1.2 µs/iter (1.04 µs … 1.42 µs) 1.22 µs 1.42 µs 1.42 µs new Response().arrayBuffer() (new string each call, utf16) 2.74 µs/iter (2.42 µs … 6.37 µs) 2.68 µs 6.37 µs 6.37 µs new Response().arrayBuffer() (existing string, latin1) 746.37 ns/iter (643.82 ns … 1.04 µs) 776.11 ns 1.04 µs 1.04 µs Peak memory usage: 104 MB bun on  jarred/memory-leak-fix took 2s ❯ mem ~/.bun/bin/bun response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 1.69 µs/iter (1.56 µs … 2.1 µs) 1.73 µs 2.1 µs 2.1 µs new Response().arrayBuffer() (new string each call, utf16) 2.65 µs/iter (2.47 µs … 3.17 µs) 2.69 µs 3.17 µs 3.17 µs new Response().arrayBuffer() (existing string, latin1) 667.67 ns/iter (547.67 ns … 1.28 µs) 694.21 ns 1.28 µs 1.28 µs Peak memory usage: 2735 MB bun on  jarred/memory-leak-fix took 2s ❯ mem ~/.bun/bin/bun --smol response-arrayBuffer.mjs cpu: Apple M1 Max runtime: bun 0.6.15 (arm64-darwin) benchmark time (avg) (min … max) p75 p99 p995 --------------------------------------------------------------------------------------------------- ----------------------------- new Response().arrayBuffer() (new string each call, latin1) 13.51 µs/iter (541 ns … 3.2 ms) 1.92 µs 553.42 µs 709.92 µs new Response().arrayBuffer() (new string each call, utf16) 13.07 µs/iter (1.71 µs … 3.43 ms) 2.13 µs 451.21 µs 651.67 µs new Response().arrayBuffer() (existing string, latin1) 6.25 µs/iter (5.79 µs … 6.81 µs) 6.4 µs 6.81 µs 6.81 µs Peak memory usage: 292 MB Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-14structured clone (#3637)Gravatar Dylan Conway 1-3/+0
* copy `SerializedScriptValue` * format * make `SerializedScriptValue` compile * add `transfer` option * tests * serialize/deserialize blobs * tests for blobs * serialize/deserialize file blobs * more tests * small cleanup * format * small changes + serialize offset * slice helper * map and set test
2023-07-12feat(bun/test): Implement "bail" option for "bun test" (#3253)Gravatar Tiramify (A.K. Daniel) 1-0/+1
* Implement bun test --bail * Fixes * move printSummary() (more readable) * Fixes 2 * idk why it got deleted * Fixes 3 * fmt this better * Update test_command.zig * Fix "0 files" * track number of files so bailing out early prints the right number --------- Co-authored-by: dave caruso <me@paperdave.net>
2023-07-11Fix: console.log with class constructors (#3602)Gravatar dave caruso 1-19/+23
* Fix console.log with class constructors * oops * fix it * lol * fix test
2023-07-02Stub out `useFakeTimers` and `useRealTimers`Gravatar Jarred Sumner 1-3/+28
2023-07-02Support mocking `new Date()` & `Date.now()` in bun:test (#3501)Gravatar Jarred Sumner 1-0/+5
* Support changing the time * Bump WebKit * Update bun.lockb --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-07-01[jest] fix lifecycle hook execution order (#3461)Gravatar Alex Lam S.L 1-82/+119
* [jest] fix lifecycle hook execution order * strip `std.debug.assert()` from release build
2023-06-29Revert "[jest] fix lifecycle hook execution order (#3447)" (#3455)Gravatar Jarred Sumner 1-96/+66
This reverts commit 182e8aa1392af9ba92beccce06f49f8e4593fe5c.
2023-06-28Use `bun.String` for `ZigException` (#3451)Gravatar Jarred Sumner 1-9/+9
* Use `bun.String` for `ZigException` * woopsie --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-28[jest] fix lifecycle hook execution order (#3447)Gravatar Alex Lam S.L 1-66/+96
2023-06-26Fix .rejectsGravatar Jarred Sumner 1-14/+7
2023-06-23Add vi.spyOn and clean up some mock function binding calls (#3376)Gravatar dave caruso 1-12/+13
* Add vi.spyOn and clean up some binding calls * add vi.restoreAllMocks * remove junk file --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-06-22`expect().resolves` and `expect().rejects` (#3318)Gravatar Ashcon Partovi 4-3824/+3650
* Move expect and snapshots to their own files * expect().resolves and expect().rejects * Fix promise being added to unhandled rejection list * Handle timeouts in expect(<promise>) * wip merge * Fix merge issue --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-21upgrade zig to `v0.11.0-dev.3737+9eb008717` (#3374)Gravatar Dylan Conway 2-9/+9
* progress * finish `@memset/@memcpy` update * Update build.zig * change `@enumToInt` to `@intFromEnum` and friends * update zig versions * it was 1 * add link to issue * add `compileError` reminder * fix merge * format * upgrade to llvm 16 * Revert "upgrade to llvm 16" This reverts commit cc930ceb1c5b4db9614a7638596948f704544ab8. --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-21finish implementing JSMockFunction prototype + lots of expect test ↵Gravatar dave caruso 1-14/+9
organizing (#3304) * mock tests * fix mistake * stuff * partially implement mock return promises * lot of housecleaning on jest tests * document / rename internalFields in jsmockfunction * finish implementing JSMockFunction prototype * cleanup * more progress * everything is done * remove demo.test.js * finish rebase * requested changes * fix compile error
2023-06-20enable asymmetric matchers in `expect.toEqual`, `expect.toStrictEqual`, and ↵Gravatar Dylan Conway 1-7/+7
`expect.toHaveProperty` (#3367) * add asymmetric matchers to `deepEquals` * fix comparison of a few jstypes * clean up and tests * fix merge * improve `expect.any` for primitives
2023-06-19feat(bun/test): Impl. "toBeArray", "toBeArrayOfSize" & "toBeTypeOf" (#3316)Gravatar Tiramify (A.K. Daniel) 2-0/+193
* Implement toBeArray, toBeArrayOfSize, toBeTypeOf * fix typos/variable names * Add testcases for regex and dates * little fix * i didn't paste that...
2023-06-11Support using `WTF::StringImpl` from Zig (#3279)Gravatar Jarred Sumner 1-0/+7
* Fix `make headers` * [JS parser] Fix bug with printing non-ascii import paths in ascii mode * Introduce `bun.String` * Add test for non-ascii imports & entry points * Add comment * Fix build issue * Support HTTP server * Make it print the same --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-09`toMatchObject` and some asymmetric matchers (#3260)Gravatar Dylan Conway 3-115/+271
* `toMatchObject` progress * add `expect.stringContaining()` * add `expect.stringMatching()` * print asymmetric matchers * cleanup * return before printing if constructor value isn't there * move matcher logic to cpp * pretty format and tests * fix formatting for snapshots * format `stringContaining` and `stringMatching` like jest * better test * remove commented tests * remove old property matcher code * add types * make sure all props are matched in arrays * add `Bun.deepMatch`
2023-06-09Implement mocks in bun:test (#3252)Gravatar Jarred Sumner 2-6/+141
* wip * wip * most of the code for mocks in bun:test * finishing up * Implement `toHaveBeenCalled` and `toHaveBeenCalledTimes(1)` * Test * visit * results, not returnValues * exact * Update jest.zig * A couple more tests * Add jest.fn * support resetting mocks * Implement spyOn --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-31Small improvements to `bun test` (#3071)Gravatar Ashcon Partovi 4-486/+1507
* Change status icon for skipped tests from "-" to "»" * Show file path instead of filename in `bun test` * Emit collapsable logs when running `bun test` in Github Actions https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines * Add fallback for test icons when emojis are not available * Only check for GITHUB_ACTIONS when running `bun test` * Emit error annotations when running `bun test` in Github Actions https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message * Remove ANSI output from Github annotation, it doesn't work * Remove outdated code from internal test runner * Add GithubActionFormatter to handle cases where error name or message is already ANSI * Fix formatting of test * Fix #3070 * Implement `bun test --run-todo` By default, `test.todo()` is no longer run, unless `--run-todo` is specified. * Fix test that relies on test.todo() being run * Support vitest-style test options * Disable GITHUB_ACTION in test harness * Add types for TestOptions * Fix bug where test.skip() actually ran * Implement `test.skipIf()` and `describe.skipIf()` * Implement `test.runIf()` * Move DiffFormatter to its own file * Fix bug where Bun.inspect() would emit a Github annotation * Introduce `bun test --only`, rename `--run-todo` to `--todo` * Implement `test.if()`, `describe.if()`, and other test fixes * Remove unwanted files from last commit * Fix last reference to --run-todo * Fix memory issues with printing github actions text * Update bindings.zig * Fix bug with `test.only()` * Remove debug test * Make the github annotations better * Improve .vscode/launch.json * Implement `expect().toBeNil()` * Remove .only() from test * Implement toBeBoolean(), toBeTrue(), toBeFalse() * Add lots of matchers * toBeNil() * toBeBoolean() * toBeTrue() * toBeFalse() * toBeNumber() * toBeInteger() * toBeFinite() * toBePositive() * toBeNegative() * toBeWithin() * toBeSymbol() * toBeFunction() * toBeDate() * toBeString() * toInclude() * toStartWith() * toEndWith() * Fix #3135 * Reduce verbosity of test * Fix snapshot bug --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-26Implement `expect().toBeEmpty()` (#3060)Gravatar Ashcon Partovi 2-9/+101
* Implement `expect().toBeEmpty()` * Fix formatting on test * Finish up expect().toBeEmpty() * Update expect.test.ts --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-26Fix crash in test.todo + remove JSC C API usages in bun:test (#3079)Gravatar Jarred Sumner 2-312/+282
* Fix crash in test.todo * remove usages of JSC C API in bun:test * Remove additional JSC-C API usages * fix `make headers` * URLSearchParams.length * FormData length * URLSearchParams length * Fix `make headers` * very fancy length * Fix bug with exceptions being ignored sometimes * Add tests for extension toHaveLength --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-24Remove that fieldGravatar Jarred Sumner 1-1/+0
2023-05-24Fix string checkGravatar Jarred Sumner 1-1/+2
2023-05-23Implement `bun test --timeout` (#3040)Gravatar Ashcon Partovi 1-6/+3
You can change the default per-test timeout in `bun test`: > bun test --timeout 10 The default timeout is 5000.
2023-05-23[bun:test] Fix async/done-based test.todo (#3015)Gravatar Jarred Sumner 1-6/+27
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-20[bun:test] `preload` now supports `beforeAll`, `beforeEach`, `afterAll`, ↵Gravatar Jarred Sumner 1-14/+116
`afterEach` hooks Towards #198
2023-05-20Implement `test.todo` (#2961)Gravatar Degreat 1-4/+69
* Implement `test.todo` * remove skip condition * Allow callbacks in .todo * Add descriptive comment * Log todos * Include tests in title * edit test.todo tests --------- Co-authored-by: dave caruso <me@paperdave.net>
2023-05-20Support test timeouts in `bun:test` (#2969)Gravatar Jarred Sumner 1-2/+66
* [bun:test] Support timeouts in `test` * make this test more resilient * :scissors: --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-19console.log changes (#2966)Gravatar Jarred Sumner 1-6/+6
* [breaking] Don't quote property names of identifiers in console.log * Make UTF-16 strings green * always quote for jest * update tests * Update this --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>