pomdtr/test_explorer

References

Referenced 4 times

Test Explorer

3c584b1ccdd2115d031f49d69f2ac68ea33c450bbde9fdd462036dc2cbf8e907.png

Click on the play button next to list items to run them.

Usage

  1. Fork this val

  2. Create new tests in any of vals (and export them) (see @pomdtr/example_test)

Create valimport { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts"; import { Test } from "https://esm.town/v/<account>/test_explorer"; export const exampleTestSuccess = new Test(() => { assertEquals(1 + 1, 2); }); export const exampleTestFailure = new Test(() => { assertEquals(1 + 1, 3); });
  1. Go to https://<account>-test_explorer.web.val.run to run your test
    • click on the val name to go to the val the tests are originating from
    • click on the test name to run it

ℹ️ You probably want to protect your test explorer behind an authentication middleware like @pomdtr/basicAuth

Discovery mechanism

In order to define a test, the user need to import the Test class from https://val.town/v/<account>/Test. So we can use the api to search for vals containing the https://val.town/v/<account>/Test string to locate the vals containing tests.

Next, we need to extract the tests from the val exports. We use exported instanceof Test to filter them (at some point we will probably use static analysis for this).

TODO

  • persist test results in sqlite
  • Improve styling (help welcome ❤️)
  • View logs in a modal
  • Batch http requests
Readme
1
2
3
4
5
import { router } from "https://esm.town/v/pomdtr/test_explorer_router";
export { Test } from "https://esm.town/v/pomdtr/test";
export default router.fetch;
1
2
3
4
5
6
7
8
9
10
import { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts";
import { Test } from "https://esm.town/v/pomdtr/test_explorer";
export const exampleTestSuccess = new Test(() => {
assertEquals(1 + 1, 2);
});
export const exampleTestFailure = new Test(() => {
assertEquals(1 + 1, 3);
});
1
2
3
4
5
6
7
8
9
10
import { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts";
import { Test } from "https://esm.town/v/pomdtr/test_explorer";
export const exampleTestFailure1 = new Test(() => {
assertEquals(1 + 1, 3);
});
export const exampleTestFailure2 = new Test(() => {
assertEquals(1 + 1, 3);
});
1
2
3
4
5
6
7
8
9
10
import { assertEquals } from "https://deno.land/std@0.216.0/assert/mod.ts";
import { Test } from "https://esm.town/v/pomdtr/test_explorer";
export const exampleTestSuccess1 = new Test(() => {
assertEquals(1 + 1, 2);
});
export const exampleTestSuccess2 = new Test(() => {
assertEquals(1 + 1, 2);
});
1
Next