From bdf80916879504d5b69745792984e8b92bfb474c Mon Sep 17 00:00:00 2001 From: Hugh Willson Date: Wed, 20 Dec 2017 18:45:03 -0500 Subject: [PATCH] Update meteor create --full to use meteortesting:mocha (#9489) This commit updates the `meteor create --full` app skeleton to use `meteortesting:mocha` (and npm based `chai`), instead of the deprecated `practicalmeteor:mocha` package. --- tools/cli/commands.js | 7 ++++++- tools/cli/default-npm-deps.js | 10 +++++++--- tools/static-assets/skel-full/.meteor/packages | 3 +-- .../skel-full/imports/api/links/links.tests.js | 2 +- .../skel-full/imports/api/links/methods.tests.js | 2 +- .../imports/api/links/server/publications.tests.js | 2 +- tools/static-assets/skel-full/package.json | 6 +++++- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tools/cli/commands.js b/tools/cli/commands.js index dda2af3804..b588c9e32a 100644 --- a/tools/cli/commands.js +++ b/tools/cli/commands.js @@ -796,7 +796,12 @@ main.registerCommand({ // the packages (or maybe an unpredictable subset based on what happens to be // in the template's versions file). - require("./default-npm-deps.js").install(appPath); + // Since some of the project skeletons include npm `devDependencies`, we need + // to make sure they're included when running `npm install`. + require("./default-npm-deps.js").install( + appPath, + { includeDevDependencies: true } + ); var appNameToDisplay = appPathAsEntered === "." ? "current directory" : `'${appPathAsEntered}'`; diff --git a/tools/cli/default-npm-deps.js b/tools/cli/default-npm-deps.js index 95df83b24d..4d4fa2a5c7 100644 --- a/tools/cli/default-npm-deps.js +++ b/tools/cli/default-npm-deps.js @@ -8,7 +8,7 @@ import { const INSTALL_JOB_MESSAGE = "installing npm dependencies"; -export function install(appDir) { +export function install(appDir, options) { const packageJsonPath = pathJoin(appDir, "package.json"); const needTempPackageJson = ! statOrNull(packageJsonPath); @@ -25,9 +25,13 @@ export function install(appDir) { } const ok = buildmessage.enterJob(INSTALL_JOB_MESSAGE, function () { - const { runNpmCommand } = require("../isobuild/meteor-npm.js"); + const npmCommand = ["install"]; + if (options && options.includeDevDependencies) { + npmCommand.push("--production=false"); + } - const installResult = runNpmCommand(["install"], appDir); + const { runNpmCommand } = require("../isobuild/meteor-npm.js"); + const installResult = runNpmCommand(npmCommand, appDir); if (! installResult.success) { buildmessage.error( "Could not install npm dependencies for test-packages: " + diff --git a/tools/static-assets/skel-full/.meteor/packages b/tools/static-assets/skel-full/.meteor/packages index f08e5df524..31294f8311 100644 --- a/tools/static-assets/skel-full/.meteor/packages +++ b/tools/static-assets/skel-full/.meteor/packages @@ -21,6 +21,5 @@ kadira:flow-router # FlowRouter is a very simple router for Meteor kadira:blaze-layout # Layout manager for blaze (works well with FlowRouter) less # Leaner CSS language - -practicalmeteor:mocha # A package for writing and running your meteor app and package tests with mocha +meteortesting:mocha # A package for writing and running your meteor app and package tests with mocha johanbrook:publication-collector # Test a Meteor publication by collecting its output diff --git a/tools/static-assets/skel-full/imports/api/links/links.tests.js b/tools/static-assets/skel-full/imports/api/links/links.tests.js index 786423b998..3f700304fe 100644 --- a/tools/static-assets/skel-full/imports/api/links/links.tests.js +++ b/tools/static-assets/skel-full/imports/api/links/links.tests.js @@ -3,7 +3,7 @@ // https://guide.meteor.com/testing.html import { Meteor } from 'meteor/meteor'; -import { assert } from 'meteor/practicalmeteor:chai'; +import { assert } from 'chai'; import { Links } from './links.js'; if (Meteor.isServer) { diff --git a/tools/static-assets/skel-full/imports/api/links/methods.tests.js b/tools/static-assets/skel-full/imports/api/links/methods.tests.js index 7c22fd81e3..8011df3759 100644 --- a/tools/static-assets/skel-full/imports/api/links/methods.tests.js +++ b/tools/static-assets/skel-full/imports/api/links/methods.tests.js @@ -3,7 +3,7 @@ // https://guide.meteor.com/testing.html import { Meteor } from 'meteor/meteor'; -import { assert } from 'meteor/practicalmeteor:chai'; +import { assert } from 'chai'; import { Links } from './links.js'; import './methods.js'; diff --git a/tools/static-assets/skel-full/imports/api/links/server/publications.tests.js b/tools/static-assets/skel-full/imports/api/links/server/publications.tests.js index 5281df275c..8725954ae8 100644 --- a/tools/static-assets/skel-full/imports/api/links/server/publications.tests.js +++ b/tools/static-assets/skel-full/imports/api/links/server/publications.tests.js @@ -2,7 +2,7 @@ // // https://guide.meteor.com/testing.html -import { assert } from 'meteor/practicalmeteor:chai'; +import { assert } from 'chai'; import { Links } from '../links.js'; import { PublicationCollector } from 'meteor/johanbrook:publication-collector'; import './publications.js'; diff --git a/tools/static-assets/skel-full/package.json b/tools/static-assets/skel-full/package.json index 9be1d6125c..23d9ed9935 100644 --- a/tools/static-assets/skel-full/package.json +++ b/tools/static-assets/skel-full/package.json @@ -2,10 +2,14 @@ "name": "~name~", "private": true, "scripts": { - "start": "meteor run" + "start": "meteor run", + "test": "meteor test --once --driver-package meteortesting:mocha" }, "dependencies": { "@babel/runtime": "^7.0.0-beta.34", "meteor-node-stubs": "^0.3.2" + }, + "devDependencies": { + "chai": "^4.1.2" } }