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

Enable babel for tests #4564

Merged
merged 4 commits into from Oct 12, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .istanbul.yml
@@ -1,3 +1,5 @@
instrumentation:
root: .
excludes: "**/node_modules/**"
excludes:
- "**/node_modules/**"
- "scripts/*.js"
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -14,6 +14,7 @@
"babel-plugin-transform-runtime": "^6.3.13",
"babel-preset-es2015": "^6.13.2",
"babel-preset-stage-0": "^6.0.0",
"babel-register": "^6.14.0",
"babel-runtime": "^6.0.0",
"browserify": "^11.2.0",
"bundle-collapser": "^1.2.1",
Expand Down
3 changes: 0 additions & 3 deletions packages/babel-cli/test/index.js
@@ -1,5 +1,3 @@
if (process.env.running_under_istanbul) return;

var readdir = require("fs-readdir-recursive");
var helper = require("babel-helper-fixtures");
var assert = require("assert");
Expand Down Expand Up @@ -79,7 +77,6 @@ var buildTest = function (binName, testName, opts) {
var binLoc = path.join(__dirname, "../lib", binName);

return function (callback) {
this.timeout(5000);
clear();
saveInFiles(opts.inFiles);

Expand Down
37 changes: 15 additions & 22 deletions packages/babel-core/test/option-manager.js
@@ -1,29 +1,22 @@
var assert = require("assert");
var OptionManager = require("../lib/transformation/file/options/option-manager");
var Logger = require("../lib/transformation/file/logger");
var path = require("path");
import assert from "assert";
import OptionManager from "../lib/transformation/file/options/option-manager";
import Logger from "../lib/transformation/file/logger";
import path from "path";

suite("option-manager", function () {
suite("memoisePluginContainer", function () {
test("throws for babel 5 plugin", function() {
suite("option-manager", () => {
suite("memoisePluginContainer", () => {
test("throws for babel 5 plugin", () => {
return assert.throws(
function () {
OptionManager.memoisePluginContainer(
function (ref) {
var Plugin = ref.Plugin;
return new Plugin("object-assign", {});
}
);
},
() => OptionManager.memoisePluginContainer(({ Plugin }) => new Plugin("object-assign", {})),
/Babel 5 plugin is being run with Babel 6/
);
})
});

suite("mergeOptions", function () {
test("throws for removed babel 5 options", function() {
suite("mergeOptions", () => {
test("throws for removed babel 5 options", () => {
return assert.throws(
function () {
() => {
var opt = new OptionManager(new Logger(null, "unknown"));
opt.init({
'randomOption': true
Expand All @@ -33,9 +26,9 @@ suite("option-manager", function () {
);
});

test("throws for removed babel 5 options", function() {
test("throws for removed babel 5 options", () => {
return assert.throws(
function () {
() => {
var opt = new OptionManager(new Logger(null, "unknown"));
opt.init({
'auxiliaryComment': true,
Expand All @@ -46,9 +39,9 @@ suite("option-manager", function () {
);
});

test("throws for resolved but erroring preset", function() {
test("throws for resolved but erroring preset", () => {
return assert.throws(
function () {
() => {
var opt = new OptionManager(new Logger(null, "unknown"));
opt.init({
'presets': [path.join(__dirname, "fixtures/option-manager/not-a-preset")]
Expand Down
23 changes: 23 additions & 0 deletions scripts/babel-register.js
@@ -0,0 +1,23 @@
var babel = require("../package.json").babel;
var register = require("babel-register");
var path = require("path");

if (babel.plugins) {
// correct path of relative plugins
babel.plugins = babel.plugins.map(function (plugin) {
if (plugin.charAt(0) === '.') {
return plugin.replace(/^\./, path.join(__dirname, '..'));
}

return plugin;
});
}

register(babel);
register({
extensions: [".js"],
// Only js files in the test folder but not in the subfolder fixtures.
only: /packages\/.+\/test\/(?!fixtures\/).+\.js$/,
babelrc: false,
compact: true,
});
2 changes: 1 addition & 1 deletion test/mocha.opts
@@ -1 +1 @@
--reporter dot --ui tdd --timeout 10000
--reporter dot --ui tdd --timeout 10000 --compilers js:./scripts/babel-register