https://github.com/dahlia/web_deno_test
Run your tests on Deno and web browsers at a time
https://github.com/dahlia/web_deno_test
deno deno-test deno-tools tests unit-tests web-testing
Last synced: 6 months ago
JSON representation
Run your tests on Deno and web browsers at a time
- Host: GitHub
- URL: https://github.com/dahlia/web_deno_test
- Owner: dahlia
- License: lgpl-3.0
- Created: 2021-04-23T17:28:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-26T13:52:43.000Z (over 4 years ago)
- Last Synced: 2025-03-07T06:06:15.744Z (7 months ago)
- Topics: deno, deno-test, deno-tools, tests, unit-tests, web-testing
- Language: TypeScript
- Homepage: https://deno.land/x/web_deno_test
- Size: 16.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
web_deno_test: Run your tests on Deno and web browsers at a time
================================================================[![Latest version][Tag badge]][Deno module]
[![LGPL 3.0][License badge]](./LICENSE)
[![GitHub Actions status][GitHub Actions status badge]][GitHub Actions status]This script enables your test suite to run on Deno and web browsers at a time.
[Tag badge]: https://img.shields.io/github/v/tag/dahlia/web_deno_test
[Deno module]: https://deno.land/x/web_deno_test
[License badge]: https://img.shields.io/github/license/dahlia/web_deno_test
[GitHub Actions status badge]: https://github.com/dahlia/web_deno_test/actions/workflows/test.yaml/badge.svg
[GitHub Actions status]: https://github.com/dahlia/web_deno_test/actions/workflows/test.yamlHow to write tests
------------------You need to use the `suite()` function from *mod.ts*:
~~~~ typescript
import { assertEquals } from "https://deno.land/std@0.92.0/testing/asserts.ts";
import suite from "https://deno.land/x/web_deno_test/mod.ts";const test = suite(import.meta.url);
test("1 plus 2 equals 3", () => {
assertEquals(1 + 2, 3);
});
~~~~How to run tests on Deno
------------------------The standard Deno test command works:
~~~~ bash
$ deno test
Check file:///.../$deno$test.ts
running 1 tests
test 1 plus 2 equals 3 ... ok (3ms)test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (3ms)
~~~~How to run tests on web browsers
--------------------------------The *cli.ts* script scans test files and turns them into [Mocha]-based
tests:~~~~ bash
$ deno run \
--unstable \
--allow-read=. \
--allow-write=tests/ \
--allow-net \
https://deno.land/x/web_deno_test/cli.ts \
--output-dir tests/ \
.
Check .../cli.ts
~~~~Note that the script requires `--unstable` API as of Deno 1.9.
The built *index.html* should be opened through `http:`/`https:` (not `file:`)
on web browser due to security policies:~~~~ bash
$ deno run \
--allow-net \
--allow-read=. \
https://deno.land/std/http/file_server.ts \
tests/
~~~~Then, open on your web browser. It will run your tests:

[Mocha]: https://mochajs.org/