question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable power assert

See original GitHub issue

Description

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:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
jfmengelscommented, Aug 26, 2016

I’d like to work on this. I want to get more accustomed to the AVA codebase.

3reactions
xjamundxcommented, Aug 23, 2016

My personal favorite power-assert issue from last week was failing the same test over and over again

screen shot 2016-08-18 at 11 08 32 am
Read more comments on GitHub >

github_iconTop Results From Across the Web

Assert function in Power Apps Test Studio - Microsoft Learn
Enable and Disable functions in Power Apps - Power Platform. Reference information including syntax and examples for the Enable and Disable ...
Read more >
Correct syntax to disable the concurrent assertion on its first ...
Hi,. I have a concurrent assertion and want to disable it by virtue of its name on its first failure as it would...
Read more >
How do I get rid of this power assertion from a dead process?
I had the same issue: a PreventUserIdleDisplaySleep assertion set by a process that was no longer active. Killing the powerd process (to be...
Read more >
debugging - Disable assertions in Python - Stack Overflow
Using the -O flag (capital O) disables all assert statements in a process. For example: $ python -Oc "assert False" $ python -c...
Read more >
SVA: The Power of Assertions in SystemVerilog - page 76
Usually, we are interested in checking an assertion only when the reset signal · in the whole assertion. · If the disable condition...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found