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

Tutorial on unit tests doesn't work #72

Open
maxlein opened this issue Dec 10, 2023 · 1 comment
Open

Tutorial on unit tests doesn't work #72

maxlein opened this issue Dec 10, 2023 · 1 comment

Comments

@maxlein
Copy link

maxlein commented Dec 10, 2023

I am trying to run unit tests like described here, but it seems to me that the helper is not correctly initialized.

So if I try to load my node, I get an undefined logger:

    load(testNode, testFlow, testCredentials, cb) {
        const log = this._log;
        console.log("logger: " + log);  // -> undefined
logger: undefined

TypeError: Cannot read properties of undefined (reading 'log')
    at Function.spy (node_modules/sinon/lib/sinon/spy.js:156:61)
    at Sandbox.spy (node_modules/sinon/lib/sinon/sandbox.js:328:35)
    at NodeTestHelper.load (node_modules/node-red-node-test-helper/index.js:179:53)
    at Context.<anonymous> (test/lower-case_spec.js:14:16)
    at process.processImmediate (node:internal/timers:476:21)

package versions:

  "node-red" : {
    "version": ">=2.0.0",
    "nodes": {
      "lower-case": "lower-case.js"
    }
  },
  "dependencies": {
  },
  "devDependencies": {
    "mocha": "^10.2.0",
    "node-red-node-test-helper": "^0.3.2"
  }
@maxlein
Copy link
Author

maxlein commented Dec 10, 2023

Ok, the documentation page is outdated...
It's missing helper.init(require.resolve('node-red'));

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

1 participant