Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:(e2e) added test case for mevn info command #141

Merged
merged 1 commit into from
Dec 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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