Skip to content

Commit

Permalink
fix: test setup
Browse files Browse the repository at this point in the history
refactor: change let to const

Co-authored-by: Thakur Karthik <[email protected]>
  • Loading branch information
jamesgeorge007 and ThakurKarthik committed Dec 23, 2019
1 parent ea6bd13 commit f83663a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions __e2e__/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand All @@ -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();
});
});
16 changes: 16 additions & 0 deletions __e2e__/commands/info.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
...common,
displayName: 'e2e',
setupFiles: ['<rootDir>/jest/setupE2eTests.js'],
testMatch: ['<rootDir>/**/__e2e__/*{.,-}test.js'],
testMatch: ['<rootDir>/__e2e__/**/*.test.js'],
}
],
};
5 changes: 5 additions & 0 deletions jest/helpers.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"lint-staged": {
"*.js": "npm run lint"
"src/**/*.js": "npm run lint"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f83663a

Please sign in to comment.