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

Error running tests right after adapter creation with typescript #1084

Closed
watho opened this issue Jan 13, 2024 · 3 comments
Closed

Error running tests right after adapter creation with typescript #1084

watho opened this issue Jan 13, 2024 · 3 comments

Comments

@watho
Copy link

watho commented Jan 13, 2024

Adapter creation is successful with dev-server running and showing the new adapter, but running the tests leads to an failure.

step to reproduce

  1. Successful: npx @iobroker/create-adapter@latest
  2. Successful: npm run build
  3. Successful: dev-server run
  4. npm run test:ts
    leads to
> iobroker.adapter-create-test@0.0.1 test:ts
> mocha --config test/mocharc.custom.json src/**/*.test.ts


✖ ERROR: Error: Cannot find module 'tsx/cjs'
Require stack:
- /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/nodejs/esm-utils.js
- /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/mocha.js
- /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/one-and-dones.js
- /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/options.js
- /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/bin/mocha.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
    at Module._load (node:internal/modules/cjs/loader:975:27)
    at Module.require (node:internal/modules/cjs/loader:1225:19)
    at require (node:internal/modules/helpers:177:18)
    at exports.requireOrImport (/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/nodejs/esm-utils.js:53:16)
    at async exports.handleRequires (/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/run-helpers.js:94:28)
    at async /tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/run.js:349:25 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/nodejs/esm-utils.js',
    '/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/mocha.js',
    '/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/one-and-dones.js',
    '/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/lib/cli/options.js',
    '/tmp/adaptertest/ioBroker.adapter-create-test/node_modules/mocha/bin/mocha.js'
  ]
}

@AlCalzone
Copy link
Collaborator

Ah damn, I must have replaced one occurrence of "ts-node" too many.

Replace "tsx/cjs" with "ts-node/register" as a workaround.

@watho
Copy link
Author

watho commented Jan 13, 2024

Thx. Replacing it in test/mocharc.custom.json works for me.

watho pushed a commit to watho/ioBroker.smart-race-event-receiver that referenced this issue Jan 14, 2024
@AlCalzone
Copy link
Collaborator

fixed by #1086

AlCalzone added a commit that referenced this issue Jan 15, 2024
* (AlCalzone) Fixed an issue with TypeScript tests caused by #1082 (fixes #1084)
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