Browser tests now use the current mocha/chai versions. Pkg description updated

This commit is contained in:
juanelas 2020-02-29 01:07:20 +01:00
parent 1af645e98f
commit bbdee4b5a5
3 changed files with 13 additions and 7 deletions

View File

@ -9,6 +9,9 @@ const multiEntry = require('rollup-plugin-multi-entry');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const pkgJson = require('../package.json'); const pkgJson = require('../package.json');
const pkg_name = pkgJson.name;
const mocha_version = pkgJson.devDependencies.mocha.replace(/[\^~*><=]/g, '');
const chai_version = pkgJson.devDependencies.chai.replace(/[\^~*><=]/g, '');
const rootDir = path.join(__dirname, '..'); const rootDir = path.join(__dirname, '..');
@ -21,13 +24,16 @@ const dstFileName = path.join(dstDir, 'index.html');
const template = fs.readFileSync(templatePath, 'utf-8'); const template = fs.readFileSync(templatePath, 'utf-8');
const testsJs = ` const testsJs = `
<script type="module"> <script type="module">
import * as ${camelise(pkgJson.name)} from '${path.relative(templatePath, pkgJson.browser)}' import * as ${camelise(pkg_name)} from '${path.relative(templatePath, pkgJson.browser)}'
window.${camelise(pkgJson.name)} = ${camelise(pkgJson.name)}; window.${camelise(pkg_name)} = ${camelise(pkg_name)};
import './tests.js'; import './tests.js';
mocha.run(); mocha.run();
</script> </script>
`; `;
fs.writeFileSync(dstFileName, template.replace('{{TESTS}}', testsJs).replace('{{PKG_NAME}}', pkgJson.name));
fs.writeFileSync(dstFileName,
template.replace(/{{TESTS}}/g, testsJs).replace(/{{PKG_NAME}}/g, pkgJson.name).replace(/{{MOCHA_VERSION}}/g, mocha_version).replace(/{{CHAI_VERSION}}/g, chai_version)
);
/* /*
Now we create a bundle of all the tests called test.js Now we create a bundle of all the tests called test.js

View File

@ -1,7 +1,7 @@
{ {
"name": "bigint-crypto-utils", "name": "bigint-crypto-utils",
"version": "2.4.3", "version": "2.4.3",
"description": "Utils for working with cryptography using native JS (stage 3) implementation of BigInt. It includes arbitrary precision modular arithmetics, cryptographically secure random numbers and strong probable prime generation/testing.", "description": "Utils for working with cryptography using native JS implementation of BigInt. It includes arbitrary precision modular arithmetics, cryptographically secure random numbers and strong probable prime generation/testing.",
"keywords": [ "keywords": [
"modular arithmetics", "modular arithmetics",
"crypto", "crypto",

View File

@ -2,12 +2,12 @@
<html> <html>
<head> <head>
<title>{{PKG_NAME}} - Mocha Tests</title> <title>{{PKG_NAME}} - Mocha Tests</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/6.1.4/mocha.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/{{MOCHA_VERSION}}/mocha.min.css">
</head> </head>
<body> <body>
<div id="mocha"></div> <div id="mocha"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/6.1.4/mocha.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/{{MOCHA_VERSION}}/mocha.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/{{CHAI_VERSION}}/chai.min.js"></script>
<script>mocha.setup('bdd'); mocha.setup({ timeout: 90000 });</script> <script>mocha.setup('bdd'); mocha.setup({ timeout: 90000 });</script>
{{TESTS}} {{TESTS}}