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

update to new power-assert-runtime #903

Merged
merged 3 commits into from
Jun 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/caching-precompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ CachingPrecompiler.prototype._createEspowerPlugin = function () {

// initialize power-assert
return createEspowerPlugin(this.babel, {
embedAst: true,
patterns: enhanceAssert.PATTERNS
});
};
Expand Down
12 changes: 6 additions & 6 deletions lib/enhance-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ function enhanceAssert(opts) {
}

function formatter() {
var powerAssertFormatter = require('power-assert-formatter');
var powerAssertRenderers = require('power-assert-renderers');
var createFormatter = require('power-assert-context-formatter');
var SuccinctRenderer = require('power-assert-renderer-succinct');
var AssertionRenderer = require('power-assert-renderer-assertion');

return powerAssertFormatter({
maxDepth: 3,
return createFormatter({
renderers: [
powerAssertRenderers.AssertionRenderer,
powerAssertRenderers.SuccinctRenderer
{ctor: AssertionRenderer},
{ctor: SuccinctRenderer, options: {maxDepth: 3}}
]
});
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"babel-core": "^6.3.21",
"babel-plugin-ava-throws-helper": "0.0.4",
"babel-plugin-detective": "^1.0.2",
"babel-plugin-espower": "^2.1.0",
"babel-plugin-espower": "^2.2.0",
"babel-plugin-transform-runtime": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-2": "^6.3.13",
Expand All @@ -104,7 +104,7 @@
"convert-source-map": "^1.2.0",
"core-assert": "^0.2.0",
"debug": "^2.2.0",
"empower-core": "^0.5.0",
"empower-core": "^0.6.1",
"figures": "^1.4.0",
"find-cache-dir": "^0.1.1",
"fn-name": "^2.0.0",
Expand Down Expand Up @@ -132,8 +132,9 @@
"package-hash": "^1.1.0",
"pkg-conf": "^1.0.1",
"plur": "^2.0.0",
"power-assert-formatter": "^1.3.0",
"power-assert-renderers": "^0.1.0",
"power-assert-context-formatter": "^1.0.4",
"power-assert-renderer-assertion": "^1.0.1",
"power-assert-renderer-succinct": "^1.0.1",
"pretty-ms": "^2.0.0",
"repeating": "^2.0.0",
"require-precompiled": "^0.1.0",
Expand All @@ -149,6 +150,7 @@
"update-notifier": "^0.7.0"
},
"devDependencies": {
"babel-preset-react": "^6.5.0",
"cli-table2": "^0.2.0",
"coveralls": "^2.11.4",
"delay": "^1.3.0",
Expand Down
18 changes: 16 additions & 2 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,13 @@ function generateTests(prefix, apiCreator) {
});

test(prefix + 'power-assert support', function (t) {
t.plan(3);
t.plan(5);

var api = apiCreator();
var api = apiCreator({
babelConfig: {
presets: ['react', 'es2015', 'stage-2']
}
});

api.run([path.join(__dirname, 'fixture/power-assert.js')])
.then(function (result) {
Expand All @@ -667,6 +671,16 @@ function generateTests(prefix, apiCreator) {
result.errors[1].error.message,
/with message\s+t\.true\(a === 'foo', 'with message'\)\s*\n\s+\|\s*\n\s+"bar"/m
);

t.match(
result.errors[2].error.message,
/t\.true\(o === \{ ...o \}\)\s*\n\s+\|\s*\n\s+Object\{\}/m
);

t.match(
result.errors[3].error.message,
/t\.true\(<div \/> === <span \/>\)/m
);
});
});

Expand Down
12 changes: 12 additions & 0 deletions test/fixture/power-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,15 @@ test.serial(t => {

t.true(a === 'foo', 'with message');
});

test.serial(t => {
const o = {};

t.true(o === {...o});
});

test.serial(t => {
const React = { createElement: function(type) { return type } }

t.true(<div /> === <span />);
});