Skip to content

External macros are not transformed with power-assert #25

Open
@MethodGrab

Description

@MethodGrab

Description

External AVA macros are not transformed with power-assert.

Expected

Macros in the same file as the tests (internal macros) should have the same behaviour as those imported from an external file.
Both tests should output the same style of error:

test( 'internalMacro: 2 + 2 === 4', internalMacro, '2 + 2', 8 );
test( 'externalMacro: 2 + 2 === 4', externalMacro, '2 + 2', 8 );

Actual

External macros are not transformed with power-assert and so display standard errors.

Test Source

Full example: https://github.com/MethodGrab/ava-power-assert-external-macro-test-case

test.js:

import test from 'ava';

import { externalMacro } from './macros';

function internalMacro( t, input, expected ) {
    console.log( 'running internal macro...' );
    t.is( eval( input ), expected );
}

// this will output a power-assert error
test( 'internalMacro: 2 + 2 === 4', internalMacro, '2 + 2', 8 );

// this will output a standard assert error
test( 'externalMacro: 2 + 2 === 4', externalMacro, '2 + 2', 8 );

macros.js:

module.exports.externalMacro = function( t, input, expected ) {
    console.log( 'running external macro...' );
    t.is( eval( input ), expected );
}

Error Message & Stack Trace

running internal macro...
  × internalMacro: 2 + 2 === 4
  t.is(eval(input), expected)
       |    |       |
       4    "2 + 2" 8

running external macro...
  × externalMacro: 2 + 2 === 4 4 === 8

  2 tests failed [23:18:50]


  1. internalMacro: 2 + 2 === 4
  AssertionError:
    4    "2 + 2" 8
        Test.internalMacro (test.js:7:4)
        _combinedTickCallback (internal/process/next_tick.js:67:7)
        process._tickCallback (internal/process/next_tick.js:98:9)


  2. externalMacro: 2 + 2 === 4
  AssertionError: 4 === 8
    Test.module.exports.externalMacro (macros.js:3:4)
    _combinedTickCallback (internal/process/next_tick.js:67:7)
    process._tickCallback (internal/process/next_tick.js:98:9)

Config

{
  "ava": {}
}

Command-Line Arguments

ava --verbose test.js

Relevant Links

Environment

  • Node.js v6.3.0
  • win32 6.1.7601
  • npm 3.10.5
  • ava 0.16.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions