2020-03-09 20:06:47 -04:00
|
|
|
# Deno runtime tests
|
|
|
|
|
|
|
|
Files in this directory are unit tests for Deno runtime.
|
|
|
|
|
|
|
|
Testing Deno runtime code requires checking API under different runtime
|
2021-04-27 07:14:01 -04:00
|
|
|
permissions. To accomplish this all tests exercised are created using
|
|
|
|
`unitTest()` function.
|
2020-03-09 20:06:47 -04:00
|
|
|
|
2021-01-04 09:55:57 -05:00
|
|
|
```ts
|
2020-03-09 20:06:47 -04:00
|
|
|
import { unitTest } from "./test_util.ts";
|
|
|
|
|
|
|
|
unitTest(function simpleTestFn(): void {
|
|
|
|
// test code here
|
|
|
|
});
|
|
|
|
|
2021-01-04 09:55:57 -05:00
|
|
|
unitTest(
|
|
|
|
{
|
2020-04-28 12:35:23 -04:00
|
|
|
ignore: Deno.build.os === "windows",
|
2021-09-30 03:26:15 -04:00
|
|
|
permissions: { read: true, write: true },
|
2020-03-09 20:06:47 -04:00
|
|
|
},
|
|
|
|
function complexTestFn(): void {
|
|
|
|
// test code here
|
2021-01-04 09:55:57 -05:00
|
|
|
},
|
2020-03-09 20:06:47 -04:00
|
|
|
);
|
|
|
|
```
|
|
|
|
|
2020-03-14 06:53:20 -04:00
|
|
|
## Running tests
|
|
|
|
|
2021-08-11 10:20:47 -04:00
|
|
|
There are two ways to run `unit_test_runner.ts`:
|
2020-03-14 06:53:20 -04:00
|
|
|
|
2021-01-04 09:55:57 -05:00
|
|
|
```sh
|
2021-04-27 07:14:01 -04:00
|
|
|
# Run all tests.
|
2021-08-21 08:32:05 -04:00
|
|
|
target/debug/deno test --allow-all --unstable --location=http://js-unit-tests/foo/bar cli/tests/unit/
|
2020-04-21 09:48:44 -04:00
|
|
|
|
2021-04-27 07:14:01 -04:00
|
|
|
# Run a specific test module
|
2021-08-21 08:32:05 -04:00
|
|
|
target/debug/deno test --allow-all --unstable --location=http://js-unit-tests/foo/bar cli/tests/unit/files_test.ts
|
2020-03-14 06:53:20 -04:00
|
|
|
```
|
|
|
|
|
2020-03-15 12:58:59 -04:00
|
|
|
### Http server
|
2020-03-14 06:53:20 -04:00
|
|
|
|
2020-07-04 13:05:01 -04:00
|
|
|
`target/debug/test_server` is required to run when one's running unit tests.
|
|
|
|
During CI it's spawned automatically, but if you want to run tests manually make
|
|
|
|
sure that server is spawned otherwise there'll be cascade of test failures.
|