From f83663a3eed8123440965c7ec452f0937a5bb46b Mon Sep 17 00:00:00 2001 From: jamesgeorge007 Date: Mon, 23 Dec 2019 23:17:43 +0530 Subject: [PATCH] fix: test setup refactor: change let to const Co-authored-by: Thakur Karthik --- __e2e__/cli.test.js | 6 +++--- __e2e__/commands/info.test.js | 16 ++++++++++++++++ jest.config.js | 2 +- jest/helpers.js | 5 +++++ package.json | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 __e2e__/commands/info.test.js diff --git a/__e2e__/cli.test.js b/__e2e__/cli.test.js index 91c2b11c7..b25ee960d 100644 --- a/__e2e__/cli.test.js +++ b/__e2e__/cli.test.js @@ -10,14 +10,14 @@ test('shows up help if no arguments were passed', () => { test('show up help information on passing in the respective options', () => { ['-h', '--help'].forEach(op => { - let { stdout } = run([op]); + const { stdout } = run([op]); expect(stdout).toMatchSnapshot(); }); }); test('show up CLI version information', () => { ['-V', '--version'].forEach(op => { - let { stdout } = run([op]); + const { stdout } = run([op]); expect(stdout).toMatchSnapshot(); }); }); @@ -41,4 +41,4 @@ test('warns the user if an unknown command is passed', () => { test('suggests the matching command if the user makes a typo', () => { const { stdout } = run(['ini']); expect(stdout).toMatchSnapshot(); -}); \ No newline at end of file +}); diff --git a/__e2e__/commands/info.test.js b/__e2e__/commands/info.test.js new file mode 100644 index 000000000..605b72ab7 --- /dev/null +++ b/__e2e__/commands/info.test.js @@ -0,0 +1,16 @@ +'use strict'; + +import { run } from '../../jest/helpers'; +import envinfo from 'envinfo'; + +test('mevn info', async () => { + const { stdout } = await run(['info']); + const data = await envinfo + .run({ + System: ['OS', 'CPU'], + Binaries: ['Node', 'Yarn', 'npm'], + Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'], + npmGlobalPackages: ['mevn-cli'], + }); + expect(stdout).toContain(data); +}); \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index 8c83a6783..578ce458a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,7 +6,7 @@ module.exports = { ...common, displayName: 'e2e', setupFiles: ['/jest/setupE2eTests.js'], - testMatch: ['/**/__e2e__/*{.,-}test.js'], + testMatch: ['/__e2e__/**/*.test.js'], } ], }; diff --git a/jest/helpers.js b/jest/helpers.js index 968e3cbec..c2b79b242 100644 --- a/jest/helpers.js +++ b/jest/helpers.js @@ -1,8 +1,13 @@ 'use strict'; +import 'babel-polyfill'; import execa from 'execa'; import path from 'path'; const CLI_PATH = path.resolve(process.cwd(), 'bin', 'mevn.js'); +// sync version export const run = args => execa.sync(CLI_PATH, args); + +// async version +export const runAsync = async args => await execa(CLI_PATH, args); diff --git a/package.json b/package.json index 3e4baa682..d431036d1 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ } }, "lint-staged": { - "*.js": "npm run lint" + "src/**/*.js": "npm run lint" }, "repository": { "type": "git",