SUI-Components/sui

server tests crash on node v12.21.0

alextremp opened this issue · 0 comments

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.