plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.18k stars 280 forks source link

chore: TS test fixes #436

Open benallfree opened 7 months ago

benallfree commented 7 months ago

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: