mirror of
https://github.com/strapi/strapi.git
synced 2025-12-30 00:37:24 +00:00
fix: version test to check for valid semver
This commit is contained in:
parent
2314bc3311
commit
b017a1ae07
@ -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",
|
||||
|
||||
38
tests/cli/tests/strapi/version/version.test.cli.js
Normal file
38
tests/cli/tests/strapi/version/version.test.cli.js
Normal 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`);
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user