Disable power assert
See original GitHub issueDescription
As amazing as power-assert
is, it’s constantly causing my team problems. Often it results in reeeeally weird behavior (for example, sometimes suddenly AVA thinks we have infinite tests and runs them like it’s got a mind of its own until we kill the process). Often the issues involve JSX, enzyme wrappers, objects with circular references, and upcoming JS features.
Many of the problems that have come up with power-assert in the past have been fixed which is awesome, but it’s still just too much magic for my team to stay productive and still causes us a great deal of grief. I love it when it works, but I just don’t think that we can keep using it. We’re seriously considering changing frameworks because of this (and some perf issues which I know are being worked on).
Proposal
Expose a config to disable power-assert:
{
"ava": {
"powerAssert": false
}
}
Then this:
var defaultPlugins = lazy(function () {
return [
espowerPlugin(),
require('babel-plugin-ava-throws-helper'),
rewritePlugin(),
require('babel-plugin-transform-runtime')
];
});
function build(babelConfig, filePath, code) {
// ...
objectAssign(options, {
inputSourceMap: sourceMap,
filename: filePath,
sourceMaps: true,
ast: false
});
// ...
options.plugins = (options.plugins || []).concat(defaultPlugins());
// ...
}
Could be changed to this:
var defaultPlugins = lazy(function (options) {
return [
options.powerAssert ? espowerPlugin() : null,
require('babel-plugin-ava-throws-helper'),
rewritePlugin(),
require('babel-plugin-transform-runtime')
].filter(plugin => !!plugin); // filter out null plugins
});
function build(babelConfig, filePath, code) {
// ...
objectAssign(options, {
inputSourceMap: sourceMap,
filename: filePath,
sourceMaps: true,
ast: false,
powerAssert: true
});
// ...
options.plugins = (options.plugins || []).concat(defaultPlugins(options));
// ...
}
Here’s a diff
:
- var defaultPlugins = lazy(function () {
+ var defaultPlugins = lazy(function (options) {
return [
- espowerPlugin()
+ options.powerAssert ? espowerPlugin() : null,
require('babel-plugin-ava-throws-helper'),
rewritePlugin(),
require('babel-plugin-transform-runtime')
- ]
+ ].filter(plugin => !!plugin); // filter out null plugins
});
function build(babelConfig, filePath, code) {
// ...
objectAssign(options, {
inputSourceMap: sourceMap,
filename: filePath,
sourceMaps: true,
- ast: false
+ ast: false,
+ powerAssert: true
});
// ...
- options.plugins = (options.plugins || []).concat(defaultPlugins());
+ options.plugins = (options.plugins || []).concat(defaultPlugins(options));
// ...
}
Without actually testing this, it seems to me like it would work. Thoughts? 💭
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
I’d like to work on this. I want to get more accustomed to the AVA codebase.
My personal favorite power-assert issue from last week was failing the same test over and over again