Skip to content

Commit 946b3cb

Browse files
author
Jake Champion
committed
make test use version from package.json
1 parent 0f7ba73 commit 946b3cb

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

integration-tests/cli/help.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import test from 'brittle';
22
import { getBinPath } from 'get-bin-path'
33
import { prepareEnvironment } from '@jakechampion/cli-testing-library';
4+
import { readFileSync } from "node:fs";
5+
import { fileURLToPath } from "node:url";
6+
import { dirname, join } from "node:path";
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
9+
const packageJson = readFileSync(join(__dirname, "../../package.json"), {
10+
encoding: "utf-8",
11+
});
12+
const version = JSON.parse(packageJson).version;
413

514
const cli = await getBinPath()
615

@@ -13,7 +22,7 @@ test('--help should return help on stdout and zero exit code', async function (t
1322

1423
t.is(code, 0);
1524
t.alike(stdout, [
16-
'js-compute-runtime 0.5.4',
25+
`js-compute-runtime ${version}`,
1726
'USAGE:',
1827
'js-compute-runtime [FLAGS] [OPTIONS] [ARGS]',
1928
'FLAGS:',
@@ -37,7 +46,7 @@ test('-h should return help on stdout and zero exit code', async function (t) {
3746

3847
t.is(code, 0);
3948
t.alike(stdout, [
40-
'js-compute-runtime 0.5.4',
49+
`js-compute-runtime ${version}`,
4150
'USAGE:',
4251
'js-compute-runtime [FLAGS] [OPTIONS] [ARGS]',
4352
'FLAGS:',

integration-tests/cli/version.test.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import test from 'brittle';
22
import { getBinPath } from 'get-bin-path'
33
import { prepareEnvironment } from '@jakechampion/cli-testing-library';
4+
import { readFileSync } from "node:fs";
5+
import { fileURLToPath } from "node:url";
6+
import { dirname, join } from "node:path";
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
9+
const packageJson = readFileSync(join(__dirname, "../../package.json"), {
10+
encoding: "utf-8",
11+
});
12+
const version = JSON.parse(packageJson).version;
413

514
const cli = await getBinPath()
615

@@ -12,7 +21,7 @@ test('--version should return version number on stdout and zero exit code', asyn
1221
const { code, stdout, stderr } = await execute(process.execPath, `${cli} --version`);
1322

1423
t.is(code, 0);
15-
t.alike(stdout, ['js-compute-runtime 0.5.4'])
24+
t.alike(stdout, [`js-compute-runtime ${version}`])
1625
t.alike(stderr, [])
1726
});
1827

@@ -24,6 +33,6 @@ test('-V should return version number on stdout and zero exit code', async funct
2433
const { code, stdout, stderr } = await execute(process.execPath, `${cli} -V`);
2534

2635
t.is(code, 0);
27-
t.alike(stdout, ['js-compute-runtime 0.5.4'])
36+
t.alike(stdout, [`js-compute-runtime ${version}`])
2837
t.alike(stderr, [])
2938
});

0 commit comments

Comments
 (0)