Skip to content

Commit

Permalink
fix tests (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Dec 1, 2023
1 parent da90469 commit f236fe3
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions test/test-integration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@
import * as path from 'path';
import { createHelpers } from 'yeoman-test';
import * as cp from 'child_process';
import which from 'which';

import * as assert from 'assert';

import { fileURLToPath } from 'url';

describe('integration tests', async function () {
describe('integration tests', function () {
this.timeout(5 * 60 * 1000);

const helpers = createHelpers();
const appLocation = path.join(fileURLToPath(import.meta.url), '../../generators/app');

const npmLocation = await which('npm')

it('command-ts integration test (install, compile and run extension tests)', async () => {

const runResult = await helpers.run(appLocation).withAnswers({
Expand All @@ -32,18 +29,18 @@ describe('integration tests', async function () {
});

//console.log('command-ts with test: Running npm install');
const res = await doSpawn(npmLocation, ['i'], { cwd: runResult.env.cwd });
const res = await doSpawn('npm', ['i'], { cwd: runResult.env.cwd });
if (res.exitCode !== 0) {
assert.fail(`npm installed failed: stdout ${res.stdout} stderr ${res.stderr}`);
}

const resAudit = await doSpawn(npmLocation, ['audit'], { cwd: runResult.env.cwd });
const resAudit = await doSpawn('npm', ['audit'], { cwd: runResult.env.cwd });
if (resAudit.exitCode !== 0) {
assert.fail(`npm audit failed: stdout ${resAudit.stdout} stderr ${resAudit.stderr}`);
}

//console.log('command-ts with test: Running extension compile');
const res2 = await doSpawn(npmLocation, ['run', 'test'], { cwd: runResult.env.cwd });
const res2 = await doSpawn('npm', ['run', 'test'], { cwd: runResult.env.cwd });
if (res2.exitCode !== 0) {
assert.fail(`npm run test failed: stdout ${res2.stdout} stderr ${res2.stderr}`);
}
Expand All @@ -65,18 +62,18 @@ describe('integration tests', async function () {
openWith: 'skip'
});

const res = await doSpawn(npmLocation, ['i'], { cwd: runResult.env.cwd });
const res = await doSpawn('npm', ['i'], { cwd: runResult.env.cwd });
if (res.exitCode !== 0) {
assert.fail(`npm installed failed: stdout ${res.stdout} stderr ${res.stderr}`);
}

const resAudit = await doSpawn(npmLocation, ['audit'], { cwd: runResult.env.cwd });
const resAudit = await doSpawn('npm', ['audit'], { cwd: runResult.env.cwd });
if (resAudit.exitCode !== 0) {
assert.fail(`npm audit failed: stdout ${resAudit.stdout} stderr ${resAudit.stderr}`);
}

//console.log('command-ts-webpack with test: Running extension compile');
const res2 = await doSpawn(npmLocation, ['run', 'test'], { cwd: runResult.env.cwd });
const res2 = await doSpawn('npm', ['run', 'test'], { cwd: runResult.env.cwd });
if (res2.exitCode !== 0) {
assert.fail(`npm run compile failed: stdout ${res2.stdout} stderr ${res2.stderr}`);
}
Expand All @@ -97,18 +94,18 @@ describe('integration tests', async function () {
openWith: 'skip'
});

const res = await doSpawn(npmLocation, ['i'], { cwd: runResult.env.cwd });
const res = await doSpawn('npm', ['i'], { cwd: runResult.env.cwd });
if (res.exitCode !== 0) {
assert.fail(`npm installed failed: stdout ${res.stdout} stderr ${res.stderr}`);
}

const resAudit = await doSpawn(npmLocation, ['audit'], { cwd: runResult.env.cwd });
const resAudit = await doSpawn('npm', ['audit'], { cwd: runResult.env.cwd });
if (resAudit.exitCode !== 0) {
assert.fail(`npm audit failed: stdout ${resAudit.stdout} stderr ${resAudit.stderr}`);
}

//console.log('command-ts-web with test: Running extension compile-web');
const res2 = await doSpawn(npmLocation, ['run', 'test'], { cwd: runResult.env.cwd });
const res2 = await doSpawn('npm', ['run', 'test'], { cwd: runResult.env.cwd });
if (res2.exitCode !== 0) {
assert.fail(`npm run test failed: stdout ${res2.stdout} stderr ${res2.stderr}`);
}
Expand All @@ -120,7 +117,7 @@ describe('integration tests', async function () {

async function doSpawn(execName, allArguments, options) {
return new Promise((resolve, reject) => {
const child = cp.spawn(execName, allArguments, { stdio: 'inherit', ...options });
const child = cp.execFile(execName, allArguments, { stdio: 'inherit', ...options });
child.on('error', (err) => {
reject(err);
});
Expand Down

0 comments on commit f236fe3

Please sign in to comment.