From dc7faabf8c1b76e33ecf7e39653adcb3378a9faa Mon Sep 17 00:00:00 2001 From: Armano Date: Sun, 26 Jan 2020 23:42:00 +0100 Subject: [PATCH 1/4] test(travis-cli): migrate tests from ava to jest --- @commitlint/cli/src/cli.test.js | 2 +- @commitlint/travis-cli/package.json | 20 --- @commitlint/travis-cli/src/cli.test.js | 207 ++++++++++++------------- jest.config.js | 1 + 4 files changed, 98 insertions(+), 132 deletions(-) diff --git a/@commitlint/cli/src/cli.test.js b/@commitlint/cli/src/cli.test.js index d5abe33dce..9f66db8431 100644 --- a/@commitlint/cli/src/cli.test.js +++ b/@commitlint/cli/src/cli.test.js @@ -5,7 +5,7 @@ import {merge} from 'lodash'; import * as sander from 'sander'; import stream from 'string-to-stream'; -const bin = path.normalize(path.join(__dirname, '../lib/cli.js')); +const bin = require.resolve('../lib/cli.js'); const cli = (args, options) => { return (input = '') => { diff --git a/@commitlint/travis-cli/package.json b/@commitlint/travis-cli/package.json index 65a7348399..d726e696db 100644 --- a/@commitlint/travis-cli/package.json +++ b/@commitlint/travis-cli/package.json @@ -13,27 +13,8 @@ "deps": "dep-check", "pkg": "pkg-check --skip-main", "start": "ava -c 4 --verbose --watch", - "test": "ava -c 4 --verbose", "watch": "babel src --out-dir lib --watch --source-maps" }, - "ava": { - "files": [ - "src/**/*.test.js" - ], - "source": [ - "lib/**/*.js" - ], - "babel": { - "testOptions": { - "presets": [ - "babel-preset-commitlint" - ] - } - }, - "require": [ - "@babel/register" - ] - }, "babel": { "presets": [ "babel-preset-commitlint" @@ -66,7 +47,6 @@ "@babel/register": "7.7.7", "@commitlint/test": "8.2.0", "@commitlint/utils": "^8.3.4", - "ava": "2.4.0", "babel-preset-commitlint": "^8.2.0", "cross-env": "6.0.3", "which": "2.0.1" diff --git a/@commitlint/travis-cli/src/cli.test.js b/@commitlint/travis-cli/src/cli.test.js index bf26a03b14..396309ceca 100644 --- a/@commitlint/travis-cli/src/cli.test.js +++ b/@commitlint/travis-cli/src/cli.test.js @@ -1,14 +1,11 @@ -// Disable ftb -// const os = require('os'); -// const {git} = require('@commitlint/test'); -import test from 'ava'; import execa from 'execa'; // Disable ftb -// const which = require('which'); +// import {git} from '@commitlint/test'; +// import which from 'which'; // Disable ftb // const NODE_BIN = which.sync('node'); -const BIN = require.resolve('../lib/cli.js'); +const bin = require.resolve('../lib/cli.js'); // Disable ftb // const TRAVIS_COMMITLINT_BIN = require.resolve('../fixtures/commitlint'); @@ -16,68 +13,60 @@ const BIN = require.resolve('../lib/cli.js'); // const TRAVIS_BRANCH = 'TRAVIS_BRANCH'; // const TRAVIS_COMMIT = 'TRAVIS_COMMIT'; -const bin = async (config = {}) => { +const cli = async (config = {}) => { try { - return await execa(BIN, Object.assign({extendEnv: false}, config)); + return await execa(bin, [], config); } catch (err) { - throw new Error([err.stdout, err.stderr].join('\n')); + return Promise.reject([err.stdout, err.stderr].join('\n')); } }; -test('should throw when not on travis ci', async t => { +test('should throw when not on travis ci', async () => { const env = { CI: false, TRAVIS: false }; - await t.throwsAsync( - bin({env}), - /@commitlint\/travis-cli is intended to be used on Travis CI/ + await expect(cli({env})).rejects.toContain( + '@commitlint/travis-cli is intended to be used on Travis CI' ); }); -/* Test.failing( - 'should throw when on travis ci, but env vars are missing', - async t => { - const env = { - TRAVIS: true, - CI: true - }; +test('should throw when on travis ci, but env vars are missing', async () => { + const env = { + TRAVIS: true, + CI: true + }; - await t.throwsAsync(bin({env}), /TRAVIS_COMMIT, TRAVIS_BRANCH/); - } -); */ + await expect(cli({env})).rejects.toContain( + 'TRAVIS_COMMIT, TRAVIS_COMMIT_RANGE, TRAVIS_EVENT_TYPE, TRAVIS_REPO_SLUG, TRAVIS_PULL_REQUEST_SLUG' + ); +}); -test('should throw when on travis ci, but TRAVIS_COMMIT is missing', async t => { +test('should throw when on travis ci, but TRAVIS_COMMIT is missing', async () => { const env = { TRAVIS: true, CI: true }; - await t.throwsAsync(bin({env}), /TRAVIS_COMMIT/); + await expect(cli({env})).rejects.toContain('TRAVIS_COMMIT'); }); -/* Test.failing( - 'should throw when on travis ci, but TRAVIS_BRANCH is missing', - async t => { - const env = { - TRAVIS: true, - CI: true - }; - - await t.throwsAsync(bin({env}), /TRAVIS_BRANCH/); - } -); +test('should throw when on travis ci, but TRAVIS_BRANCH is missing', async () => { + const env = { + TRAVIS: true, + CI: true + }; -test.failing('should call git with expected args on shallow repo', async t => { - if (os.platform() === 'win32') { - t.pass(); - return; - } + await expect(cli({env})).rejects.toContain('TRAVIS_BRANCH'); +}); - const cwd = await git.clone('https://github.com/conventional-changelog/commitlint.git', [ - '--depth=10' - ]); +/* +test('should call git with expected args on shallow repo', async () => { + const cwd = await git.clone( + 'https://github.com/conventional-changelog/commitlint.git', + ['--depth=10'] + ); const env = { TRAVIS: true, @@ -88,7 +77,7 @@ test.failing('should call git with expected args on shallow repo', async t => { TRAVIS_COMMITLINT_GIT_BIN }; - const result = await bin({cwd, env}); + const result = await cli({cwd, env}); const invocations = await getInvocations(result.stdout); t.is(invocations.length, 7); @@ -143,76 +132,72 @@ test.failing('should call git with expected args on shallow repo', async t => { ]); }); -test.failing( - 'should call git with expected args on unshallow repo', - async t => { - if (os.platform() === 'win32') { - t.pass(); - return; - } - - const cwd = await git.clone('https://github.com/conventional-changelog/commitlint.git'); - - const env = { - TRAVIS: true, - CI: true, - TRAVIS_BRANCH, - TRAVIS_COMMIT, - TRAVIS_COMMITLINT_BIN, - TRAVIS_COMMITLINT_GIT_BIN - }; - - const result = await bin({cwd, env}); - const invocations = await getInvocations(result.stdout); - t.is(invocations.length, 6); - - const [stash, branches, checkout, back, pop, commilint] = invocations; - - t.deepEqual(stash, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash']); - t.deepEqual(branches, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'remote', - 'set-branches', - 'origin', - TRAVIS_BRANCH - ]); - t.deepEqual(checkout, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - TRAVIS_BRANCH, - '--quiet' - ]); - t.deepEqual(back, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - '-', - '--quiet' - ]); - t.deepEqual(pop, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash', 'pop']); - t.deepEqual(commilint, [ - NODE_BIN, - TRAVIS_COMMITLINT_BIN, - '--from', - TRAVIS_BRANCH, - '--to', - TRAVIS_COMMIT - ]); - } -); +test('should call git with expected args on unshallow repo', async () => { + const cwd = await git.clone( + 'https://github.com/conventional-changelog/commitlint.git' + ); + + const env = { + TRAVIS: true, + CI: true, + TRAVIS_BRANCH, + TRAVIS_COMMIT, + TRAVIS_COMMITLINT_BIN, + TRAVIS_COMMITLINT_GIT_BIN + }; + + const result = await cli({cwd, env}); + const invocations = await getInvocations(result.stdout); + t.is(invocations.length, 6); + + const [stash, branches, checkout, back, pop, commilint] = invocations; + + t.deepEqual(stash, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash']); + t.deepEqual(branches, [ + NODE_BIN, + TRAVIS_COMMITLINT_GIT_BIN, + 'remote', + 'set-branches', + 'origin', + TRAVIS_BRANCH + ]); + t.deepEqual(checkout, [ + NODE_BIN, + TRAVIS_COMMITLINT_GIT_BIN, + 'checkout', + TRAVIS_BRANCH, + '--quiet' + ]); + t.deepEqual(back, [ + NODE_BIN, + TRAVIS_COMMITLINT_GIT_BIN, + 'checkout', + '-', + '--quiet' + ]); + t.deepEqual(pop, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash', 'pop']); + t.deepEqual(commilint, [ + NODE_BIN, + TRAVIS_COMMITLINT_BIN, + '--from', + TRAVIS_BRANCH, + '--to', + TRAVIS_COMMIT + ]); +}); function getInvocations(stdout) { const matches = stdout.match(/[^[\]]+/g); const raw = Array.isArray(matches) ? matches : []; - return raw.filter(invocation => invocation !== '\n').map(invocation => - invocation - .split(',') - .map(fragment => fragment.trim()) - .map(fragment => fragment.substring(1, fragment.length - 1)) - .filter(Boolean) - ); + return raw + .filter(invocation => invocation !== '\n') + .map(invocation => + invocation + .split(',') + .map(fragment => fragment.trim()) + .map(fragment => fragment.substring(1, fragment.length - 1)) + .filter(Boolean) + ); } */ diff --git a/jest.config.js b/jest.config.js index 28a58f4c92..7f52d46531 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,6 +5,7 @@ module.exports = { testMatch: [ '**/*.test.ts?(x)', '**/@commitlint/read/src/*.test.js?(x)', + '**/@commitlint/travis-cli/src/*.test.js?(x)', '**/@commitlint/cli/src/*.test.js?(x)' ] }; From c9e4c8c7706f2283aef0ef37ab7e67868ba4cbf3 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 27 Jan 2020 00:25:32 +0100 Subject: [PATCH 2/4] test(travis-cli): remove redundant tests --- @commitlint/travis-cli/src/cli.test.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/@commitlint/travis-cli/src/cli.test.js b/@commitlint/travis-cli/src/cli.test.js index 396309ceca..0ce4ab844b 100644 --- a/@commitlint/travis-cli/src/cli.test.js +++ b/@commitlint/travis-cli/src/cli.test.js @@ -43,24 +43,6 @@ test('should throw when on travis ci, but env vars are missing', async () => { ); }); -test('should throw when on travis ci, but TRAVIS_COMMIT is missing', async () => { - const env = { - TRAVIS: true, - CI: true - }; - - await expect(cli({env})).rejects.toContain('TRAVIS_COMMIT'); -}); - -test('should throw when on travis ci, but TRAVIS_BRANCH is missing', async () => { - const env = { - TRAVIS: true, - CI: true - }; - - await expect(cli({env})).rejects.toContain('TRAVIS_BRANCH'); -}); - /* test('should call git with expected args on shallow repo', async () => { const cwd = await git.clone( From 1449c6b94a69a600d0d241b59855ff1d79304183 Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 27 Jan 2020 01:17:54 +0100 Subject: [PATCH 3/4] test(travis-cli): fix and enable mocked tests --- @commitlint/travis-cli/fixtures/commitlint.js | 9 +- @commitlint/travis-cli/fixtures/git.js | 9 +- @commitlint/travis-cli/package.json | 5 +- @commitlint/travis-cli/src/cli.js | 2 +- @commitlint/travis-cli/src/cli.test.js | 169 +++++------------- @packages/test/src/git.ts | 23 ++- yarn.lock | 7 - 7 files changed, 83 insertions(+), 141 deletions(-) diff --git a/@commitlint/travis-cli/fixtures/commitlint.js b/@commitlint/travis-cli/fixtures/commitlint.js index 333349df2e..4ab757da04 100755 --- a/@commitlint/travis-cli/fixtures/commitlint.js +++ b/@commitlint/travis-cli/fixtures/commitlint.js @@ -1,2 +1,9 @@ #!/usr/bin/env node -console.log(process.argv); + +const args = process.argv; +args.shift(); // remove node +console.log( + args.map((item, index) => { + return index === 0 ? 'commitlint' : item; + }) +); diff --git a/@commitlint/travis-cli/fixtures/git.js b/@commitlint/travis-cli/fixtures/git.js index 333349df2e..7a66985b45 100755 --- a/@commitlint/travis-cli/fixtures/git.js +++ b/@commitlint/travis-cli/fixtures/git.js @@ -1,2 +1,9 @@ #!/usr/bin/env node -console.log(process.argv); + +const args = process.argv; +args.shift(); // remove node +console.log( + args.map((item, index) => { + return index === 0 ? 'git' : item; + }) +); diff --git a/@commitlint/travis-cli/package.json b/@commitlint/travis-cli/package.json index d726e696db..d8fdc71225 100644 --- a/@commitlint/travis-cli/package.json +++ b/@commitlint/travis-cli/package.json @@ -42,14 +42,13 @@ }, "license": "MIT", "devDependencies": { - "@babel/core": "7.7.7", "@babel/cli": "7.7.7", + "@babel/core": "7.7.7", "@babel/register": "7.7.7", "@commitlint/test": "8.2.0", "@commitlint/utils": "^8.3.4", "babel-preset-commitlint": "^8.2.0", - "cross-env": "6.0.3", - "which": "2.0.1" + "cross-env": "6.0.3" }, "dependencies": { "@commitlint/cli": "^8.3.5", diff --git a/@commitlint/travis-cli/src/cli.js b/@commitlint/travis-cli/src/cli.js index 085ecd4a9e..f6e2177c44 100755 --- a/@commitlint/travis-cli/src/cli.js +++ b/@commitlint/travis-cli/src/cli.js @@ -77,7 +77,7 @@ async function lint(args, options) { } async function log(hash) { - const result = await execa('git', [ + const result = await execa(GIT, [ 'log', '-n', '1', diff --git a/@commitlint/travis-cli/src/cli.test.js b/@commitlint/travis-cli/src/cli.test.js index 0ce4ab844b..5cc453dd6d 100644 --- a/@commitlint/travis-cli/src/cli.test.js +++ b/@commitlint/travis-cli/src/cli.test.js @@ -1,17 +1,22 @@ import execa from 'execa'; -// Disable ftb -// import {git} from '@commitlint/test'; -// import which from 'which'; +import {git} from '@commitlint/test'; -// Disable ftb -// const NODE_BIN = which.sync('node'); const bin = require.resolve('../lib/cli.js'); -// Disable ftb -// const TRAVIS_COMMITLINT_BIN = require.resolve('../fixtures/commitlint'); -// const TRAVIS_COMMITLINT_GIT_BIN = require.resolve('../fixtures/git'); -// const TRAVIS_BRANCH = 'TRAVIS_BRANCH'; -// const TRAVIS_COMMIT = 'TRAVIS_COMMIT'; +const TRAVIS_COMMITLINT_BIN = require.resolve('../fixtures/commitlint'); +const TRAVIS_COMMITLINT_GIT_BIN = require.resolve('../fixtures/git'); + +const validBaseEnv = { + TRAVIS: true, + CI: true, + TRAVIS_COMMIT: 'TRAVIS_COMMIT', + TRAVIS_COMMITLINT_BIN: TRAVIS_COMMITLINT_BIN, + TRAVIS_COMMITLINT_GIT_BIN: TRAVIS_COMMITLINT_GIT_BIN, + TRAVIS_COMMIT_RANGE: 'TRAVIS_COMMIT_A.TRAVIS_COMMIT_B', + TRAVIS_EVENT_TYPE: 'TRAVIS_EVENT_TYPE', + TRAVIS_REPO_SLUG: 'TRAVIS_REPO_SLUG', + TRAVIS_PULL_REQUEST_SLUG: 'TRAVIS_PULL_REQUEST_SLUG' +}; const cli = async (config = {}) => { try { @@ -43,128 +48,53 @@ test('should throw when on travis ci, but env vars are missing', async () => { ); }); -/* -test('should call git with expected args on shallow repo', async () => { +test('should call git with expected args', async () => { const cwd = await git.clone( 'https://github.com/conventional-changelog/commitlint.git', - ['--depth=10'] - ); - - const env = { - TRAVIS: true, - CI: true, - TRAVIS_BRANCH, - TRAVIS_COMMIT, - TRAVIS_COMMITLINT_BIN, + ['--depth=10'], + __dirname, TRAVIS_COMMITLINT_GIT_BIN - }; + ); - const result = await cli({cwd, env}); + const result = await cli({ + cwd, + env: validBaseEnv + }); const invocations = await getInvocations(result.stdout); - t.is(invocations.length, 7); - - const [ - stash, - branches, - unshallow, - checkout, - back, - pop, - commilint - ] = invocations; - - t.deepEqual(stash, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash']); - t.deepEqual(branches, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'remote', - 'set-branches', - 'origin', - TRAVIS_BRANCH - ]); - t.deepEqual(unshallow, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'fetch', - '--unshallow', - '--quiet' - ]); - t.deepEqual(checkout, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - TRAVIS_BRANCH, - '--quiet' - ]); - t.deepEqual(back, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - '-', - '--quiet' - ]); - t.deepEqual(pop, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash', 'pop']); - t.deepEqual(commilint, [ - NODE_BIN, - TRAVIS_COMMITLINT_BIN, - '--from', - TRAVIS_BRANCH, - '--to', - TRAVIS_COMMIT - ]); + expect(invocations.length).toBe(3); + + const [stash, branches, commilint] = invocations; + + expect(stash).toEqual(['git', 'stash', '-k', '-u', '--quiet']); + expect(branches).toEqual(['git', 'stash', 'pop', '--quiet']); + expect(commilint).toEqual(['commitlint']); }); -test('should call git with expected args on unshallow repo', async () => { +test('should call git with expected args on pull_request', async () => { const cwd = await git.clone( - 'https://github.com/conventional-changelog/commitlint.git' - ); - - const env = { - TRAVIS: true, - CI: true, - TRAVIS_BRANCH, - TRAVIS_COMMIT, - TRAVIS_COMMITLINT_BIN, + 'https://github.com/conventional-changelog/commitlint.git', + ['--depth=10'], + __dirname, TRAVIS_COMMITLINT_GIT_BIN - }; + ); - const result = await cli({cwd, env}); + const result = await cli({ + cwd, + env: {...validBaseEnv, TRAVIS_EVENT_TYPE: 'pull_request'} + }); const invocations = await getInvocations(result.stdout); - t.is(invocations.length, 6); - - const [stash, branches, checkout, back, pop, commilint] = invocations; - - t.deepEqual(stash, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash']); - t.deepEqual(branches, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'remote', - 'set-branches', - 'origin', - TRAVIS_BRANCH - ]); - t.deepEqual(checkout, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - TRAVIS_BRANCH, - '--quiet' - ]); - t.deepEqual(back, [ - NODE_BIN, - TRAVIS_COMMITLINT_GIT_BIN, - 'checkout', - '-', - '--quiet' - ]); - t.deepEqual(pop, [NODE_BIN, TRAVIS_COMMITLINT_GIT_BIN, 'stash', 'pop']); - t.deepEqual(commilint, [ - NODE_BIN, - TRAVIS_COMMITLINT_BIN, + expect(invocations.length).toBe(3); + + const [stash, branches, commilint] = invocations; + + expect(stash).toEqual(['git', 'stash', '-k', '-u', '--quiet']); + expect(branches).toEqual(['git', 'stash', 'pop', '--quiet']); + expect(commilint).toEqual([ + 'commitlint', '--from', - TRAVIS_BRANCH, + 'TRAVIS_COMMIT_A', '--to', - TRAVIS_COMMIT + 'TRAVIS_COMMIT_B' ]); }); @@ -182,4 +112,3 @@ function getInvocations(stdout) { .filter(Boolean) ); } -*/ diff --git a/@packages/test/src/git.ts b/@packages/test/src/git.ts index 22e905749f..e459273926 100644 --- a/@packages/test/src/git.ts +++ b/@packages/test/src/git.ts @@ -9,11 +9,16 @@ export async function bootstrap(fixture?: string, directory?: string) { return cwd; } -export async function clone(source: string, ...args: string[]) { - const cwd = await fix.bootstrap(); +export async function clone( + source: string, + args: string[], + directory?: string, + gitCommand = 'git' +) { + const cwd = await fix.bootstrap(undefined, directory); - await execa('git', ['clone', ...args, source, cwd]); - await setup(cwd); + await execa(gitCommand, ['clone', ...args, source, cwd]); + await setup(cwd, gitCommand); return cwd; } @@ -23,11 +28,13 @@ export async function init(cwd: string) { return cwd; } -async function setup(cwd: string) { +async function setup(cwd: string, gitCommand = 'git') { try { - await execa('git', ['config', 'user.name', 'ava'], {cwd}); - await execa('git', ['config', 'user.email', 'test@example.com'], {cwd}); - await execa('git', ['config', 'commit.gpgsign', 'false'], {cwd}); + await execa(gitCommand, ['config', 'user.name', 'ava'], {cwd}); + await execa(gitCommand, ['config', 'user.email', 'test@example.com'], { + cwd + }); + await execa(gitCommand, ['config', 'commit.gpgsign', 'false'], {cwd}); } catch (err) { console.warn(`git config in ${cwd} failed`, err.message); } diff --git a/yarn.lock b/yarn.lock index 32df2547ef..ffe00dc1c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10172,13 +10172,6 @@ which-module@^2.0.0: resolved "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/which/-/which-2.0.1.tgz#f1cf94d07a8e571b6ff006aeb91d0300c47ef0a4" - integrity sha512-N7GBZOTswtB9lkQBZA4+zAXrjEIWAUOB93AvzUiudRzRxhUdLURQ7D/gAIMY1gatT/LTbmbcv8SiYazy3eYB7w== - dependencies: - isexe "^2.0.0" - which@^1.2.10, which@^1.2.14, which@^1.2.9, which@^1.3.0, which@^1.3.1: version "1.3.1" resolved "https://registry.npmjs.org/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" From 53ac530c7bec6ad6c0cea64c25131d872db7347a Mon Sep 17 00:00:00 2001 From: Armano Date: Mon, 27 Jan 2020 21:49:31 +0100 Subject: [PATCH 4/4] test(travis-cli): restore some original code --- @commitlint/travis-cli/src/cli.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/@commitlint/travis-cli/src/cli.test.js b/@commitlint/travis-cli/src/cli.test.js index 5cc453dd6d..9b37462aed 100644 --- a/@commitlint/travis-cli/src/cli.test.js +++ b/@commitlint/travis-cli/src/cli.test.js @@ -22,7 +22,7 @@ const cli = async (config = {}) => { try { return await execa(bin, [], config); } catch (err) { - return Promise.reject([err.stdout, err.stderr].join('\n')); + throw new Error([err.stdout, err.stderr].join('\n')); } }; @@ -32,7 +32,7 @@ test('should throw when not on travis ci', async () => { TRAVIS: false }; - await expect(cli({env})).rejects.toContain( + await expect(cli({env})).rejects.toThrow( '@commitlint/travis-cli is intended to be used on Travis CI' ); }); @@ -43,7 +43,7 @@ test('should throw when on travis ci, but env vars are missing', async () => { CI: true }; - await expect(cli({env})).rejects.toContain( + await expect(cli({env})).rejects.toThrow( 'TRAVIS_COMMIT, TRAVIS_COMMIT_RANGE, TRAVIS_EVENT_TYPE, TRAVIS_REPO_SLUG, TRAVIS_PULL_REQUEST_SLUG' ); });