Coder Social home page Coder Social logo

dahlia / web_deno_test Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 17 KB

Run your tests on Deno and web browsers at a time

Home Page: https://deno.land/x/web_deno_test

License: GNU Lesser General Public License v3.0

TypeScript 93.85% HTML 3.07% JavaScript 3.08%
deno deno-tools unit-tests tests web-testing deno-test

web_deno_test's Introduction

web_deno_test: Run your tests on Deno and web browsers at a time

Latest version LGPL 3.0 GitHub Actions status

This script enables your test suite to run on Deno and web browsers at a time.

How to write tests

You need to use the suite() function from mod.ts:

import { assertEquals } from "https://deno.land/[email protected]/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:

$ 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:

$ 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:

$ deno run \
    --allow-net \
    --allow-read=. \
    https://deno.land/std/http/file_server.ts \
    tests/

Then, open http://0.0.0.0:4507/ on your web browser. It will run your tests:

Tests ran on web browser.

web_deno_test's People

Contributors

dahlia avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

drsensor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.