Skip to content

Commit

Permalink
reinstate all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Jul 5, 2021
1 parent 8046330 commit 1264641
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 39 deletions.
59 changes: 27 additions & 32 deletions test/cli.test.js
Expand Up @@ -4,35 +4,30 @@ const coverage = global.coverage;

jest.setTimeout(20000);

it('should have a test', function () {
expect('hello world');
});

// for (const cliTest of eval(fs.readFileSync(__dirname + "/cli.js").toString())) {
// it(`should execute "ncc ${(cliTest.args || []).join(" ")}"`, async () => {
// const ps = fork(__dirname + (coverage ? "/../src/cli.js" : "/../dist/ncc/cli.js"), cliTest.args || [], {
// stdio: "pipe",
// env: { ...process.env, ...cliTest.env },
// });
// let stderr = "", stdout = "";
// ps.stderr.on("data", chunk => stderr += chunk.toString());
// ps.stdout.on("data", chunk => stdout += chunk.toString());
// const expected = cliTest.expect || { code: 0 };
// let timedOut = false;
// if (cliTest.timeout)
// setTimeout(() => {
// timedOut = true;
// ps.kill();
// }, cliTest.timeout);
// const code = await new Promise(resolve => ps.on("close", resolve));
// if (typeof expected === "function")
// expect(expected(code, stdout, stderr, timedOut)).toBe(true);
// else {
// if ("code" in expected)
// expect(code).toBe(expected.code);
// if ("timeout" in expected)
// expect(timedOut).toBe(true);
// }
// });
// }

for (const cliTest of eval(fs.readFileSync(__dirname + "/cli.js").toString())) {
it(`should execute "ncc ${(cliTest.args || []).join(" ")}"`, async () => {
const ps = fork(__dirname + (coverage ? "/../src/cli.js" : "/../dist/ncc/cli.js"), cliTest.args || [], {
stdio: "pipe",
env: { ...process.env, ...cliTest.env },
});
let stderr = "", stdout = "";
ps.stderr.on("data", chunk => stderr += chunk.toString());
ps.stdout.on("data", chunk => stdout += chunk.toString());
const expected = cliTest.expect || { code: 0 };
let timedOut = false;
if (cliTest.timeout)
setTimeout(() => {
timedOut = true;
ps.kill();
}, cliTest.timeout);
const code = await new Promise(resolve => ps.on("close", resolve));
if (typeof expected === "function")
expect(expected(code, stdout, stderr, timedOut)).toBe(true);
else {
if ("code" in expected)
expect(code).toBe(expected.code);
if ("timeout" in expected)
expect(timedOut).toBe(true);
}
});
}
1 change: 0 additions & 1 deletion test/integration.test.js
Expand Up @@ -38,7 +38,6 @@ for (const integrationTest of fs.readdirSync(__dirname + "/integration")) {
// disabled pending https://github.com/zeit/ncc/issues/141
if (integrationTest.endsWith('loopback.js')) continue;

continue;
it(`should execute "ncc run ${integrationTest}"`, async () => {
let expectedStdout;
try {
Expand Down
5 changes: 0 additions & 5 deletions test/unit.test.js
Expand Up @@ -4,12 +4,7 @@ const ncc = coverage ? require("../src/index") : require("../");

jest.setTimeout(20000);

it('Should have a test', function () {
expect('hello world');
});

for (const unitTest of fs.readdirSync(`${__dirname}/unit`)) {
continue;
it(`should generate correct output for ${unitTest}`, async () => {
const testDir = `${__dirname}/unit/${unitTest}`;
const expected = fs
Expand Down
2 changes: 1 addition & 1 deletion test/watcher.test.js
Expand Up @@ -93,7 +93,7 @@ class CustomWatchFileSystem {
}
}

jest.setTimeout(60000);
jest.setTimeout(30000);

it('Should support custom watch API', async () => {
let buildCnt = 0;
Expand Down

0 comments on commit 1264641

Please sign in to comment.