Skip to content

Conversation

@benallfree
Copy link
Contributor

This PR fixes the test suite to test plopfile.ts parsing.

Help wanted - it's currently dependent on import tsx, which I understand we do not want to do (though it works).

Without import tsx at the top, and using env vars instead, it fails:

NODE_PATH=`pwd`/node_modules NODE_OPTIONS='--import tsx' yarn test

results in errors like this:

plop:test:
plop:test:  FAIL  tests/input-processing.spec.js > should report a missing plopfile when not copied
plop:test: TestingLibraryElementError: Unable to find an stdout line with the text: /\[PLOP\] No plopfile found/. This could be because the text is broken up by multiple lines. In this case, you can provide a function for your text matcher to make your matcher more flexible.
plop:test:
plop:test:
plop:test: node:internal/process/esm_loader:34
plop:test:       internalBinding('errors').triggerUncaughtException(
plop:test:                                 ^
plop:test:
plop:test: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tsx' imported from /Volumes/Code/repos/
plop:test: Did you mean to import "tsx/dist/loader.mjs"?
plop:test:     at packageResolve (node:internal/modules/esm/resolve:854:9)
plop:test:     at moduleResolve (node:internal/modules/esm/resolve:927:18)
plop:test:     at defaultResolve (node:internal/modules/esm/resolve:1157:11)
plop:test:     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
plop:test:     at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
plop:test:     at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
plop:test:     at ModuleLoader.import (node:internal/modules/esm/loader:322:34)
plop:test:     at loadESM (node:internal/process/esm_loader:23:33)
plop:test:     at runMainESM (node:internal/modules/run_main:98:21)
plop:test:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:131:5) {
plop:test:   code: 'ERR_MODULE_NOT_FOUND'
plop:test: }
plop:test:
plop:test: Node.js v20.12.0
plop:test:
plop:test:
plop:test: node:internal/process/esm_loader:34
plop:test:       internalBinding('errors').triggerUncaughtException(
plop:test:                                 ^
plop:test:
plop:test: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'tsx' imported from /Volumes/Code/repos/
plop:test: Did you mean to import "tsx/dist/loader.mjs"?
plop:test:     at packageResolve (node:internal/modules/esm/resolve:854:9)
plop:test:     at moduleResolve (node:internal/modules/esm/resolve:927:18)
plop:test:     at defaultResolve (node:internal/modules/esm/resolve:1157:11)
plop:test:     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:390:12)
plop:test:     at ModuleLoader.resolve (node:internal/modules/esm/loader:359:25)
plop:test:     at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:234:38)
plop:test:     at ModuleLoader.import (node:internal/modules/esm/loader:322:34)
plop:test:     at loadESM (node:internal/process/esm_loader:23:33)
plop:test:     at runMainESM (node:internal/modules/run_main:98:21)
plop:test:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:131:5) {
plop:test:   code: 'ERR_MODULE_NOT_FOUND'
plop:test: }
plop:test:
plop:test: Node.js v20.12.0
plop:test:  ❯ waitForWrapper node_modules/cli-testing-library/dist/cli-testing-library.esm.js:455:27
plop:test:     456| /*
plop:test:     457| eslint
plop:test:     458|   max-lines-per-function: ["error", {"max": 200}],
plop:test:        |                ^
plop:test:     459| */
plop:test:     460|
plop:test:  ❯ node_modules/cli-testing-library/dist/cli-testing-library.esm.js:495:12
plop:test:  ❯ tests/input-processing.spec.js:11:16
plop:test:
@@ -1,5 +1,6 @@
#!/usr/bin/env node

import "tsx";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently necessary, there is something strange going on with the test runner where the normal NODE_* env vars are not getting through properly.

type: "input",
name: "name",
message: "What is your name?",
message: "What is your Typescript name?",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to differentiate the plopfile.ts from the plopfile.js content.

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

Labels

None yet

1 participant