Tone.js/test/integration/unpkg/test.mjs
Yotam Mann aaf880c925
Using web-test-runner for tests, updating import paths (#1242)
* WIP moving tests to web-test-runner

* updating thresholds

* Adding file extensions

* Testing integrations

* linting

* fixing dep

* moving back to root dir

* prettier all of the files

* updating eslint rules to use with prettier

* remove import package

* moving tsignore around

* removing unneeded ignores

* all tests run on puppeteer, no need for testing guards

* linting

* import type syntax

* cleaning up

* Update package.json
2024-05-03 14:31:14 -04:00

24 lines
738 B
JavaScript

/**
* @fileoverview Ensure that the unpkg link can be loaded in the browser
*/
import puppeteer from "puppeteer";
import { fileURLToPath } from "url";
import { readFile } from "fs/promises";
import { resolve } from "path";
import assert from "assert";
const __dirname = fileURLToPath(new URL(".", import.meta.url));
const rootDir = resolve(__dirname, "../../../");
const pkg = JSON.parse(
(await readFile(resolve(rootDir, "package.json"))).toString()
);
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.addScriptTag({
path: resolve(rootDir, pkg.unpkg),
});
const time = await page.evaluate("Tone.now()");
await browser.close();
assert(time >= 0, new Error("did not export a time value"));