From 3ce03391adbb773323beb668ff65987f11bc44aa Mon Sep 17 00:00:00 2001 From: Taranveer Virk Date: Tue, 2 Jan 2018 10:32:31 -0500 Subject: [PATCH 1/2] test: run cli tests in top level npm test --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a204654345e6..9a20e2fea4d3 100644 --- a/package.json +++ b/package.json @@ -37,9 +37,10 @@ "clean": "lerna run --loglevel=silent clean", "build": "lerna run --loglevel=silent build", "build:current": "lerna run --loglevel=silent build:current", - "pretest": "npm run build:current", + "pretest": "npm run build:current && npm run cli:link", + "cli:link": "cd packages/cli/generators/app && npm link && pwd && cd ../controller && npm link && pwd && cd ../extension && npm link && pwd && cd ../project && npm link && pwd && cd ../../.. && pwd", "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\"", "posttest": "npm run lint" }, "config": { From ee9fe8358463538127653403ab9a6fde23674aab Mon Sep 17 00:00:00 2001 From: Taranveer Virk Date: Tue, 2 Jan 2018 18:27:06 -0500 Subject: [PATCH 2/2] fix(cli): use path.sep to be platform agnostic --- package.json | 3 +-- packages/cli/test/project.js | 3 ++- packages/cli/test/test-utils.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9a20e2fea4d3..9295ff99b8a0 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,7 @@ "clean": "lerna run --loglevel=silent clean", "build": "lerna run --loglevel=silent build", "build:current": "lerna run --loglevel=silent build:current", - "pretest": "npm run build:current && npm run cli:link", - "cli:link": "cd packages/cli/generators/app && npm link && pwd && cd ../controller && npm link && pwd && cd ../extension && npm link && pwd && cd ../project && npm link && pwd && cd ../../.. && pwd", + "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\" \"packages/cli/test\"", "posttest": "npm run lint" diff --git a/packages/cli/test/project.js b/packages/cli/test/project.js index b454805f28e0..6f26f983567b 100644 --- a/packages/cli/test/project.js +++ b/packages/cli/test/project.js @@ -9,6 +9,7 @@ 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() { @@ -16,7 +17,7 @@ module.exports = function(projGenerator, props, projectType) { 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); diff --git a/packages/cli/test/test-utils.js b/packages/cli/test/test-utils.js index e749758ca724..cf362194e360 100644 --- a/packages/cli/test/test-utils.js +++ b/packages/cli/test/test-utils.js @@ -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); };