ember-cli-blueprint-test-helpers
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -19,5 +19,5 @@ 'use strict'; | ||
.then(() => emberGenerateDestroy(args, (file) => { | ||
// expect(file('app/type/foo.js)).to.contain('foo'); | ||
// expect(file('app/type/foo.js')).to.contain('foo'); | ||
})); | ||
}); | ||
}); |
var Promise = require('ember-cli/lib/ext/promise'); | ||
var existsSync = require('exists-sync'); | ||
var fs = require('fs-extra'); | ||
var path = require('path'); | ||
var merge = require('lodash.merge'); | ||
var writeFile = Promise.denodeify(fs.outputFile); | ||
module.exports = { | ||
description: 'Installs dependencies for ember-cli-blueprint-test-helpers', | ||
availableOptions: [ | ||
{ | ||
name: 'babel', | ||
type: Boolean, | ||
default: false | ||
} | ||
], | ||
normalizeEntityName: function(){}, | ||
afterInstall: function() { | ||
return Promise.all([ | ||
this.insertIntoFile('./.npmignore', 'node-tests/'), | ||
this.addPackageToProject('ember-cli-internal-test-helpers', '^0.7.0'), | ||
this.addPackageToProject('glob', '5.0.13'), | ||
this.addPackageToProject('mocha', '^2.2.1'), | ||
this.addPackageToProject('mocha-only-detector', '0.0.2'), | ||
this.addPackageToProject('rimraf', '^2.4.3'), | ||
this.addPackageToProject('rsvp','^3.0.17') | ||
]); | ||
afterInstall: function(options) { | ||
var afterInstallTasks = [ | ||
this.insertIntoFile('./.npmignore', 'node-tests/') | ||
]; | ||
var packages = [{name: 'mocha', target: '^2.2.1'}]; | ||
this.insertTestCallToPackage(options) | ||
if (options.babel) { | ||
afterInstallTasks.push(this.insertIntoJsonFile('./node-tests/.babelrc',{plugins: ["transform-es2015-arrow-functions", "transform-es2015-shorthand-properties"]})); | ||
// add babel specific packages | ||
packages.push({name: 'babel-plugin-transform-es2015-arrow-functions', target: '^6.5.2'}, | ||
{name: 'babel-plugin-transform-es2015-shorthand-properties', target: '^6.5.0'}, | ||
{name: 'babel-register', target: '^6.7.2'}); | ||
} | ||
afterInstallTasks.push(this.addPackagesToProject(packages)); | ||
return Promise.all(afterInstallTasks); | ||
}, | ||
insertIntoJsonFile: function(pathRelativeToProjectRoot, contents) { | ||
var fullPath = path.join(this.project.root, pathRelativeToProjectRoot); | ||
var contentsToWrite; | ||
var originalContents = {}; | ||
if (existsSync(fullPath)) { | ||
originalContents = JSON.parse(fs.readFileSync(fullPath, { encoding: 'utf8' })); | ||
} | ||
contentsToWrite = JSON.stringify(merge(originalContents, contents), null, 2); | ||
if (contentsToWrite !== originalContents) { | ||
return writeFile(fullPath, contentsToWrite); | ||
} else { | ||
return Promise.resolve(); | ||
} | ||
}, | ||
insertTestCallToPackage: function(options) { | ||
var insert = false; | ||
var fullPath = path.join(this.project.root, 'package.json'); | ||
var scriptContents = 'mocha node-tests --recursive'; | ||
var babelContents = ' --require babel-register'; | ||
var packageContents = fs.readJsonSync(fullPath, { throws: false }); | ||
if (packageContents.scripts.nodetest === scriptContents) { | ||
if (options.babel) { | ||
packageContents.scripts.nodetest += babelContents; | ||
insert = true; | ||
} | ||
} else if (typeof packageContents.scripts.nodetest === 'undefined') { | ||
packageContents.scripts.nodetest = scriptContents + (options.babel ? babelContents : ''); | ||
insert = true; | ||
} else { | ||
this.ui.writeLine('Could not update "nodetest" script in package.json. Please add "' + scriptContents + | ||
(options.babel ? babelContents : '') + '" to your nodetest script.'); | ||
} | ||
if (insert) { | ||
fs.writeJsonSync(fullPath, packageContents, {spaces:2}); | ||
} | ||
} | ||
}; |
'use strict'; | ||
var Promise = require('ember-cli/lib/ext/promise'); | ||
var RSVP = require('rsvp'); | ||
var Blueprint = require('ember-cli/lib/models/blueprint'); | ||
@@ -10,3 +10,3 @@ var conf = require('ember-cli-internal-test-helpers/lib/helpers/conf'); | ||
var existsSync = require('exists-sync'); | ||
var remove = Promise.denodeify(fs.remove); | ||
var remove = RSVP.denodeify(fs.remove); | ||
var tmpenv = require('./tmp-env'); | ||
@@ -23,3 +23,2 @@ var debug = require('debug')('ember-cli:testing'); | ||
@param {Object} [options.tmpenv] | ||
@return {null} | ||
*/ | ||
@@ -56,3 +55,2 @@ module.exports = function setupTestHooks(scope, options) { | ||
}); | ||
}; |
{ | ||
"name": "ember-cli-blueprint-test-helpers", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "Blueprint test helpers for ember-cli. Mocks ember-cli for generate and destroy commands.", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"lint": "mocha tests/lint-test", | ||
"test": "mocha tests --recursive" | ||
"test": "mocha tests node-tests --recursive" | ||
}, | ||
@@ -33,2 +33,3 @@ "ember-addon": { | ||
"fs-extra": "^0.26.7", | ||
"lodash.merge": "^4.4.0", | ||
"tmp-sync": "^1.0.0", | ||
@@ -35,0 +36,0 @@ "walk-sync": "^0.2.5" |
@@ -26,3 +26,9 @@ | ||
If you are using `ember-cli-blueprint-test-helpers` on Node v4.x or lower, you'll want to use the `--babel` option, to add ES6 support. | ||
``` | ||
ember generate ember-cli-blueprint-test-helpers --babel | ||
``` | ||
It should be noted that `ember-cli-blueprint-test-helpers` currently [only works for testing blueprints inside addon projects](https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/56). | ||
Usage | ||
@@ -36,3 +42,3 @@ ------------------------------------------------------------------------------ | ||
``` | ||
node node-tests/nodetest-runner.js | ||
node_modules/.bin/mocha node-tests --recursive | ||
``` | ||
@@ -44,3 +50,3 @@ | ||
"scripts": { | ||
"nodetest": "node node-tests/nodetest-runner.js" | ||
"nodetest": "mocha node-tests --recursive" | ||
} | ||
@@ -75,3 +81,3 @@ ``` | ||
return emberNew() | ||
// then generate and destroy the `my-blueprint` blueprint called `foo` | ||
@@ -85,4 +91,4 @@ .then(() => emberGenerateDestroy(args, (file) => { | ||
})); | ||
// magically done for you: assert that the generated files are destroyed again | ||
// magically done for you: assert that the generated files are destroyed again | ||
}); | ||
@@ -104,3 +110,3 @@ }); | ||
return emberNew() | ||
// then generate the `my-blueprint` blueprint called `foo` | ||
@@ -113,3 +119,3 @@ .then(() => emberGenerate(args)) | ||
.to.contain('more file contents\n')) | ||
// then destroy the `my-blueprint` blueprint called `foo` | ||
@@ -124,3 +130,2 @@ .then(() => emberDestroy(args)) | ||
API Reference | ||
@@ -146,3 +151,3 @@ ------------------------------------------------------------------------------ | ||
Prepare the test context for the blueprint tests. | ||
**Parameters:** | ||
@@ -152,4 +157,4 @@ | ||
- `{Object} [options]` optional parameters | ||
- `{Number} [options.timeout=20000]` the test timeout in milliseconds | ||
- `{Object} [options.tmpenv]` object containing info about the temporary directory for the test. | ||
- `{Number} [options.timeout=20000]` the test timeout in milliseconds | ||
- `{Object} [options.tmpenv]` object containing info about the temporary directory for the test. | ||
Defaults to [`lib/helpers/tmp-env.js`](lib/helpers/tmp-env.js) | ||
@@ -156,0 +161,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
244
6
27054
11
27
502
1
+ Addedlodash.merge@^4.4.0
+ Addedlodash.merge@4.6.2(transitive)