# Tests in Bun Bun currently has four different kinds of tests To run all the tests: ```bash make test-all bun --cwd=test/bun.js wiptest ``` ### Runtime tests To run the runtime tests: ```bash cd test/bun.js bun wiptest ``` These tests are in [./bun.js](./bun.js) and are files with `.test.js` or `.test.ts` in the filename. These test that the runtime behaves as expected. These also test the transpiler, both because test files are transpiled and directly by running the transpiler via `Bun.Transpiler`. #### Adding a new test 1. Create a new file in [./bun.js](./bun.js/) with `.test` in the name. These test use `bun:test` as the import (though you can also import from `vitest` or jest and it will work). This will eventually be a public test runner for bun, but the reporter isn't very good yet and it doesn't run in parallel. The syntax intends for Jest compatibility. ```ts import { describe, expect, it } from "bun:test"; describe("Example", () => { it("should work", () => { expect(1).toBe(1); }); }); ``` ### Browser tests Browser tests run end-to-end inside of Puppeteer and execute code transpiled by `bun dev`. These tests are in [./snippets](./snippets). The interface is: ```js // this function is called after import() // if testDone() is never called, the test fails export function test() { return testDone(import.meta.url); } ``` On success, it saves a snapshot to [./snapshots](./snapshots) which is checked into git. #### Adding a new test 1. Create a new file in the `snippets` directory. 2. Append the filename to [./scripts/snippets.json](./scripts/snippets.json) 3. Run `bun dev` inside this folder in one terminal window 4. Run `make integration-test-dev` These tests are run twice. Once with HMR enabled and once with HMR disabled. HMR changes the output enough to warrant it's own special treatment. #### Running the tests To run the browser tests with HMR on a production build: ```bash make test-with-hmr ``` To run the browser tests without HMR on a production build: ```bash make test-with-no-hmr ``` To run the browser tests with HMR on a debug build: ```bash make test-dev-with-hmr ``` To run the browser tests without HMR on a debug build: ```bash make test-dev-no-hmr ``` To run the browser tests on whatever version of bun is running on port 3000: ```bash make integration-test-dev ``` These were the first tests bun started with #### Running the tests Run `bun wiptest ${part-of-file-name}` If you run the test in the top-level bun repo directory, it will take an extra couple seconds because `bun wiptest` will scan through all of WebKit recursively. Consider running it in the `bun.js` directory instead. ### CLI tests These run the bash files in the `apps` directory. They check end-to-end that the CLI works as expected. ```bash # Install dependencies for running tests # Does not run tests make test-install # Check a Create React App created via `bun create react ./foo` returns HTML make test-create-react # Check a Next.js app created via `bun create next ./foo` SSRs successfully make test-create-next # Check that bun run works for the same CLI args passed to npm run make test-bun-run # Check that "react" installed via bun install loads successfully # and that deleting/adding updates the lockfile as expected make test-bun-install # Check that serving public paths works correctly # and that files which should be transpiled are transpiled and files which shouldn't be aren't make test-bun-dev ``` ### Zig tests These tests live in various `.zig` files throughout Bun's codebase, leveraging Zig's builtin `test` keyword. Currently, they're not run automatically nor is there a simple way to run all of them. This is an area bun needs to improve in. ylan/change-pathname-assert Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/webcrypto.mjs (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-10-17Remove ancient changelogGravatar Ashcon Partovi 1-11/+0
2023-10-17docs: fix ws.publish (#6558)Gravatar Aral Roca Gomez 1-1/+1
2023-10-17perf(bun-types): remove needless some call (#6550)Gravatar Mikhail 1-1/+1
2023-10-16fix(runtime): make some things more stable (partial jsc debug build) (#5881)Gravatar dave caruso 116-1446/+1830
2023-10-16fix(runtime): improve IPC reliability + organization pass on that code (#6475)Gravatar dave caruso 15-98/+266
2023-10-16Simplify getting Set of extentions (#4975)Gravatar Mikhail 1-3/+3
2023-10-16Fix formattingGravatar Ashcon Partovi 1-3/+1
2023-10-16fix(test): when tests run with --only the nested describe blocks `.on… (#5616)Gravatar Igor Shapiro 2-13/+45
2023-10-16perf(node:events): optimize `emit(...)` function (#5485)Gravatar Yannik Schröder 3-11/+132
2023-10-16fix: don't remove content-encoding header from header table (#5743)Gravatar Liz 2-2/+25
2023-10-16fix(sqlite) Insert .all() does not return an array #5872 (#5946)Gravatar Hugo Galan 2-7/+11
2023-10-16Fix formattingGravatar Ashcon Partovi 2-5/+4
2023-10-16Fix `Response.statusText` (#6151)Gravatar Chris Toshok 10-238/+269
2023-10-16fix-subprocess-argument-missing (#6407)Gravatar Nicolae-Rares Ailincai 4-2/+40
2023-10-16Add type parameter to `expect` (#6128)Gravatar Voldemat 1-3/+3
2023-10-16fix(node:worker_threads): ensure threadId property is exposed on worker_threa...Gravatar Jérôme Benoit 6-15/+75
2023-10-16Fix use before define bug in sqliteGravatar Ashcon Partovi 2-5/+5
2023-10-16fix(jest): fix toStrictEqual on same URLs (#6528)Gravatar João Alisson 2-13/+16
2023-10-16Fix `toHaveBeenCalled` having wrong error signatureGravatar Ashcon Partovi 1-2/+2
2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1
2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9
2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92
2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6
2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0
2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10
2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3
2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1
2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36
2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64
2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18