Ava: Power assert not working with TypeScript recipe

Created on 14 Oct 2018  路  5Comments  路  Source: avajs/ava

Description

Since I changed from ava-ts back to ava with better TypeScript support, power assert seems to have stopped working. See output below.

Same with objects or anything else.

I would expect that it prints the incorrect value (so A.B.Tester in this case) and if it's an object then the entire object or the diff.

Test Source

test('conversion - test createFullname method', async t => {
  t.true(createFullname('A.B.', '', 'Tester') === 'A.B. Tester')

  t.pass()
})

Error Message & Stack Trace

   11:   t.true(createFullname('A.B.', '', 'Tester') === 'A.B. Tester')

  Value is not `true`:

  false

Config

ava.config.js:

export default {
  "compileEnhancements": false, // Tried true as well
  "extensions": [
    "ts"
  ],
  "require": [
    "ts-node/register"
  ],
  "files": [
    "tests/*.test.ts"
  ]
}

Command-Line Arguments

Copy your npm build scripts or the ava command used:


Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

Node.js v8.12.0
linux 4.15.0-34-generic
ava 1.0.0-beta.8
npm 6.4.1

Most helpful comment

Doesn't work for me sadly :(

It just says that Value is not 'true' now for a t.true() assertion and the line number it shows is way off. Doesn't show any power assertion.

All 5 comments

Power Assert relies on compileEnhancements, which you can't use because you're using TypeScript.

(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)

Okay, can this be a feature request? I love power assert :)

I'm not quite sure how we'd combine the two. Perhaps something to revisit once we have more integrated TypeScript support.

Hi guys, I found a way to use power-assert and typescript with ava!

npm install -D espower-typescript ts-node ava

{
  // package.json
  "ava": {
    "files": [
      "test/**/*.test.ts"
    ],
    "compileEnhancements": false,
    "extensions": [
      "ts"
    ],
    "require": [
      "ts-node/register",
      "espower-typescript/guess"
    ]
  }
}

Then just run:
$ TS_NODE_TRANSPILE_ONLY=1 npx ava

Doesn't work for me sadly :(

It just says that Value is not 'true' now for a t.true() assertion and the line number it shows is way off. Doesn't show any power assertion.

Was this page helpful?
0 / 5 - 0 ratings