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

Module API (1.4.4) not working with Javascript #80

Closed
3 tasks done
mirobo opened this issue Mar 14, 2023 · 9 comments · Fixed by #88
Closed
3 tasks done

Module API (1.4.4) not working with Javascript #80

mirobo opened this issue Mar 14, 2023 · 9 comments · Fixed by #88
Assignees
Labels
bug Something isn't working

Comments

@mirobo
Copy link

mirobo commented Mar 14, 2023

Before opening, please confirm:

  • I have searched for duplicate or closed issues and discussions.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I acknowledge that I will attach a full debug log, otherwise the issue will be closed with no response.

Environment information

cypress: ^12.7.0 => 12.7.0
cypress-cloud: ^1.4.4 => 1.4.4

npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages


  System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 8.35 GB / 31.74 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.69)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @cypress/angular:  0.0.0-development
    @cypress/mount-utils:  0.0.0-development
    @cypress/react:  0.0.0-development
    @cypress/react18:  0.0.0-development
    @cypress/svelte:  0.0.0-development
    @cypress/vue:  0.0.0-development
    @cypress/vue2:  0.0.0-development
    cypress: ^12.7.0 => 12.7.0
    cypress-cloud: ^1.4.4 => 1.4.4
  npmGlobalPackages:
    corepack: 0.15.2
    npm: 8.19.3
    rimraf: 4.1.2

Describe the bug

I'm not able to use the cypress-cloud module API within a JS file.

Starting cypress-cloud via "npx cypress-cloud" works fine. But it is still a blocker since I cannot pass Cypress config options to "npx cypress-cloud".

I dynamically configure some Cypress env variables in a JavaScript file and because of it I need (it is much more convenient) to start cypress-cloud via the Module API

Expected behavior

Module API works everywhere :)

Command and Setup

Simple demo project: https://github.com/mirobo/cypress-cloud-module-api

Run commands:

  • npm i
  • node run-tests-ci.js

Full log and debug output

C:\views\_\cypress-cloud-module-api>node run-tests-ci.js
node:internal/modules/cjs/loader:544
      throw e;
      ^

Error: Cannot find module 'C:\views\_\cypress-cloud-module-api\node_modules\cypress-cloud\'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1060:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1053:15)
    at resolveExports (node:internal/modules/cjs/loader:538:14)
    at Module._findPath (node:internal/modules/cjs/loader:607:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1025:27)
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\views\_\cypress-cloud-module-api\run-tests-ci.js:1:17)
    at Module._compile (node:internal/modules/cjs/loader:1218:14) {
  code: 'MODULE_NOT_FOUND',
  path: 'C:\\views\\_\\cypress-cloud-module-api\\node_modules\\cypress-cloud\\package.json'
}

Node.js v18.13.0
@mirobo mirobo added the bug Something isn't working label Mar 14, 2023
@agoldis agoldis self-assigned this Mar 15, 2023
@agoldis
Copy link
Contributor

agoldis commented Mar 15, 2023

Thanks for reporting @mirobo, will fix ASAP

agoldis added a commit that referenced this issue Mar 16, 2023
agoldis added a commit that referenced this issue Mar 16, 2023
* fix: esm + cjs exports. Resovle #80.

* chore: add e2e export and api tests

* fix: prevent side effects on import... kind of

* fix: remove bg color for pending tests in summary

* chore: update localhost release testing docs

* chore: revent package version

* chore: update unit test snapshots

* chore: release v1.4.5-beta.0
@agoldis
Copy link
Contributor

agoldis commented Mar 16, 2023

I've published 1.4.5-beta.0 on npm - please confirm it's working for you

@mirobo
Copy link
Author

mirobo commented Mar 16, 2023

It seems like it's not published?

https://www.npmjs.com/package/cypress-cloud?activeTab=versions

image

Stupid question.. did you run these commands from your own documentation? 😉😁

cd packages/cypress-cloud
npm run release -- --preRelease=beta && npm run release:npm -- -t beta

@agoldis
Copy link
Contributor

agoldis commented Mar 16, 2023

weird
currents-2023-03-16-03 07 26@2x

@mirobo
Copy link
Author

mirobo commented Mar 16, 2023

Now I see it.. I'll get back to you later!

@mirobo
Copy link
Author

mirobo commented Mar 16, 2023

Calling the "run" function now works, but the plugin itself can no longer communicate with sorry-cypress (error 400).

I created a separate issue here: #96

@lpanger
Copy link

lpanger commented Mar 17, 2023

On node 16.13.1 I get:
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".json" for /Users/xxxx/node_modules/cypress/package.json

Is node 17+ a requirement?

On node 18.15.0
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///Users/xxxxx/node_modules/cypress/package.json" needs an import assertion of type "json"

@agoldis
Copy link
Contributor

agoldis commented Mar 17, 2023

@lpanger what version of the package are you using? We have released https://www.npmjs.com/package/cypress-cloud/v/1.4.5-beta.1, working on the production release rn.

As for the errors - it requires node 14.7.0+, weird I am not seeing those when testing locally. How do I reproduce it?

@lpanger
Copy link

lpanger commented Mar 17, 2023

https://github.com/lpanger/cypress-cloud-module-api

cypress-cloud 1.4.5-beta.1
cypress 12.8.1

clone repo and run node index.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants