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

test: run cli tests in top level npm test #825

Merged
merged 2 commits into from
Jan 3, 2018
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"test": "node packages/build/bin/run-nyc npm run mocha",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"",
"mocha": "node packages/build/bin/select-dist mocha --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\" \"packages/cli/test\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there no dist folder for the CLI tests? It should follow the existing pattern in the current command (packages/cli/dist/test/**/*.js)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjdelisle I think the CLI cannot use TypeScript because it's a Yeoman generator under the hood, which has implications on the project layout. One more reason for getting rid of Yeoman! See #844

"posttest": "npm run lint"
},
"config": {
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ const helpers = require('yeoman-test');
const yeoman = require('yeoman-environment');
const testUtils = require('./test-utils');
const sinon = require('sinon');
const path = require('path');

module.exports = function(projGenerator, props, projectType) {
return function() {
describe('help', () => {
it('prints lb4', () => {
const env = yeoman.createEnv();
const name = projGenerator.substring(
projGenerator.lastIndexOf('/') + 1
projGenerator.lastIndexOf(path.sep) + 1
);
env.register(projGenerator, 'loopback4:' + name);
const generator = env.create('loopback4:' + name);
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
'use strict';

const yeoman = require('yeoman-environment');
const path = require('path');

exports.testSetUpGen = function(genName, arg) {
arg = arg || {};
const env = yeoman.createEnv();
const name = genName.substring(genName.lastIndexOf('/') + 1);
const name = genName.substring(genName.lastIndexOf(path.sep) + 1);
env.register(genName, 'loopback4:' + name);
return env.create('loopback4:' + name, arg);
};