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

server tests crash on node v12.21.0 #1068

Closed
alextremp opened this issue Mar 4, 2021 · 0 comments · Fixed by #1069
Closed

server tests crash on node v12.21.0 #1068

alextremp opened this issue Mar 4, 2021 · 0 comments · Fixed by #1069

Comments

@alextremp
Copy link
Collaborator

Package

@s-ui/test@4.12.0

Description

With the @s-ui/studio@9.31.0 and using node v12.21.0 (npm v6.14.11),
Having two generated packages (A, B) where B depends on A and both are tested with integration tests so B test ends using A, sui-test server, an error is thrown by the Node's CJS loader:

without forcing transpilation

server config

    "sui-test": {
      "server": {
        "forceTranspilation": []
      }
    }

error

> sui-test server


mocha /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/test --require /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@s-ui/test/bin/mocha/register.js --recursive --timeout 2000 
Warning: Cannot find any files matching pattern "/Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/test"
/Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/components/service/api/node_modules/@adv-ui/adit-boros-tcf-service-reporter/lib/index.js:1
import Bootstrap from './main/infrastructure/bootstrap';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:915:16)

forcing transpilation

server config

    "sui-test": {
      "server": {
        "forceTranspilation": ["@adv-ui"]
      }
    }

error

> sui-test server


mocha /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/test --require /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@s-ui/test/bin/mocha/register.js --recursive --timeout 2000 
Warning: Cannot find any files matching pattern "/Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/test"
/Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@s-ui/test/node_modules/yargs/yargs.js:1163
      else throw err
           ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js
require() of ES modules is not supported.
require() of /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js from /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/components/service/api/node_modules/@adv-ui/adit-boros-tcf-service-reporter/lib/main/domain/BroadcastReporter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename inheritsLoose.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/alex.castells/projects/adit/frontend-adit--uilib-boros-tcf/node_modules/@babel/runtime/helpers/esm/package.json.

    at Module._extensions..js (internal/modules/cjs/loader.js:1015:13)

Steps to Reproduce

Expected behavior: Headless tests can be ran with compatible babelized code for Node

Actual behavior: Headless tests crash on node v12.21.0

Additional information

I'm actually tweaked this in local by patching the module extensions handler according to standard-things/esm#868 (comment) and will push a PR as a possibility for resolving this issue.

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

Successfully merging a pull request may close this issue.

1 participant