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

Internals exposed to the test implementation #1835

Closed
qlonik opened this issue Jun 11, 2018 · 1 comment
Closed

Internals exposed to the test implementation #1835

qlonik opened this issue Jun 11, 2018 · 1 comment

Comments

@qlonik
Copy link
Contributor

qlonik commented Jun 11, 2018

Description

Hello, I have a question about the access to internal parts from test implementation. There were talks about public API available in #1692 and #1769. However, those features were not implemented yet, and in the mean time, before beta.5 there was access to instance of Test class if non-arrow function was passed as test implementation:

test('test case', function (t) {
  console.log(this)
})

This allowed me and testcheck-js (mentioned in #1692) to implement property testing and integrate it into ava.

However, with the change pushed into beta.5 (a681ecf), there is no way to access the instance anymore and hence not possible to act and affect the instance of Test and do things that are needed for property testing.

Would you consider reverting this change, before the public API is available? Furthermore, is it possible to not bind macros to null as well (runner.js#L269..L271), and bind it to instance of Test right before the execution of macros?

Thank you!

Test Source

test('test case', function (t) {
  console.log(this)
  console.log(this.run)
})

Config

{
  "scripts": {
    "test:ava": "npx ava",
    "test:watch": "npm run test:ava -- --watch"
  },
  "ava": {
    "files": [
      "lib/**/*.test.js"
    ],
    "sources": [
      "lib/**/*.js"
    ],
    "snapshotDir": "test/snapshots",
    "verbose": true
  }
}

Environment

Node.js v10.3.0
linux 4.16.13-1-ARCH
ava 1.0.0-beta.4
npm 6.1.0
@novemberborn
Copy link
Member

The availability of the Test instance was quite accidental. I'm reluctant to restore access to it. Ironically, TestCheck.js doesn't pass it on to the test implementation either: https://github.com/leebyron/testcheck-js/blob/c7dce0773142546e1b4e208c13b87e7f8f9be253/integrations/ava-check/ava-check.js#L40

We have an open issue that will enable first-class support for tools like TestCheck.js. See #1692. I've put out a call with TestCheck.js as well: leebyron/testcheck-js#91

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants