fix: version test to check for valid semver

This commit is contained in:
Christian Capeans 2024-04-04 11:33:18 +02:00
parent 2314bc3311
commit b017a1ae07
3 changed files with 40 additions and 0 deletions

View File

@ -140,6 +140,7 @@
"prettier": "3.2.5",
"qs": "6.11.1",
"rimraf": "5.0.5",
"semver": "7.5.4",
"stream-chain": "2.2.5",
"stream-json": "1.8.0",
"supertest": "6.3.3",

View File

@ -0,0 +1,38 @@
'use strict';
const coffee = require('coffee');
const semver = require('semver');
const assert = require('assert');
const utils = require('../../../utils');
describe('--version', () => {
let appPath;
let currentVersion;
beforeAll(async () => {
const testApps = utils.instances.getTestApps();
appPath = testApps.at(0);
currentVersion = require(`${appPath}/package.json`).dependencies['@strapi/strapi'];
});
it('should output version with argument', async () => {
await coffee
.spawn('npm', ['run', '-s', 'strapi', '--', 'version'], { cwd: appPath })
.expect('stderr', '')
.expect('stdout', `${currentVersion}\n`)
.expect('code', 0)
.end();
});
it('should output version with --version', async () => {
const { stdout } = await coffee
.spawn('npm', ['run', '-s', 'strapi', '--', '--version'], { cwd: appPath })
.expect('code', 0)
.end();
const version = stdout.trim();
assert.ok(semver.valid(version), `Version ${version} is not a valid semver`);
});
});

View File

@ -26801,6 +26801,7 @@ __metadata:
prettier: "npm:3.2.5"
qs: "npm:6.11.1"
rimraf: "npm:5.0.5"
semver: "npm:7.5.4"
stream-chain: "npm:2.2.5"
stream-json: "npm:1.8.0"
supertest: "npm:6.3.3"