Skip to content

Commit

Permalink
tests ~ deno loads module without panic or prompt (while using *no pe…
Browse files Browse the repository at this point in the history
…rmissions*)
  • Loading branch information
rivy committed Aug 1, 2022
1 parent 7a830db commit 7967ad4
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/integration.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-env es6, node */
/* eslint complexity: ['error', { max: 10 }] */ // set maximum cyclomatic complexity to 10; ref: <https://eslint.org/docs/rules/complexity>
/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */

// # spell-checker:ignore (modules) Deno ESM ESMs vNodeJSMajor vNodeJSminor cyclomatic execa

Expand All @@ -13,10 +14,13 @@ const test = require('ava');
const commandExists = require('command-exists');
const spawn = require('cross-spawn');

// ? change to package.main?
const modulePath = '../build/lab/src/mod.cjs.js';
const modulePath = '../build/lab/src/mod.cjs.js'; // ? change to package.main?
const packagePath = '../package.json';

// eslint-disable-next-line security/detect-non-literal-require , security-node/detect-non-literal-require-calls
const mod = require(modulePath);
// eslint-disable-next-line security/detect-non-literal-require , security-node/detect-non-literal-require-calls
const pkg = require(packagePath);

const vNodeJS = process.versions.node.split('.');
const vNodeJSMajor = +vNodeJS[0];
Expand Down Expand Up @@ -52,6 +56,22 @@ if (!process.env.npm_config_test_dist) {
t.pass();
});
} else {
test('module loads without panic while using `--no-prompt` (Deno)', (t) => {
const denoModulePath = pkg.exports['.'].deno;

const command = 'deno';
const args = ['run', '--no-prompt', denoModulePath];
const options = { shell: true, encoding: 'utf-8' };

const { error, status, stdout } = spawn.sync(command, args, options);

if (!(error === null && status === 0)) {
t.log({ denoModulePath, error, status, stdout });
}

t.deepEqual({ error, status }, { error: null, status: 0 });
});

test('examples are executable without error (Deno)', (t) => {
// t.timeout(30000); // 30s timeout

Expand Down

0 comments on commit 7967ad4

Please sign in to comment.