Code Monkey home page Code Monkey logo

Comments (5)

agoldis avatar agoldis commented on July 19, 2024 1

@samixchoumi
You're using ESM, but the syntax of currents.config.js is CJS-like - e.g. the use of module keyword.

currents:config failed loading config file from: ReferenceError: **module** is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/samixchoumi/IdeaProjects/projectName/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
   ....

cypress-cloud will search for a configuration file at the project's root location (defined with -P --project CLI option) in the following order:

  • currents.config.js
  • currents.config.cjs
  • currents.config.mjs
    The configuration file will be read using import() expression.

Please make sure that the file is formatted according to ESM syntax.

from cypress-cloud.

agoldis avatar agoldis commented on July 19, 2024

@samixchoumi here's an example output from 1.8.0-beta.5

DEBUG=currents:* CURRENTS_API_URL=http://localhost:1234/ yarn cypress-cloud run --parallel --record --key Fgt2j7QCjNedC2zG --ci-build-id xxx

Please try rerunning with the new version

  currents:capture capturing stdout +0ms
  currents:cli parsed CLI flags { component: false, e2e: true, parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062' } +0ms
  currents:cli parsed run params: { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG' } +1ms
  currents:run run params { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG' } +0ms
  currents:run params after preprocess { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG', spec: undefined } +0ms
  currents:config loading currents config file from '/Users/agoldis/cypress-cloud/e2e/config-noesm-js/currents.config.js' +0ms
  currents:config loaded currents config from '/Users/agoldis/cypress-cloud/e2e/config-noesm-js/currents.config.js'
  currents:config {
  currents:config   e2e: { batchSize: 3 },
  currents:config   component: { batchSize: 5 },
  currents:config   projectId: 'l4zuz8'
  currents:config } +9ms
  currents:validateParams resolving currents params: { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG', spec: undefined } +0ms
  currents:validateParams resolving currents config file: { e2e: { batchSize: 3 }, component: { batchSize: 5 }, projectId: 'l4zuz8' } +0ms
  currents:validateParams validating currents params: { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG', spec: undefined, cloudServiceUrl: 'http://localhost:1234/', projectId: 'l4zuz8', batchSize: 3 } +0ms
  currents:validateParams validated currents params: { parallel: true, record: true, headed: false, key: 'Fgt2j7QCjNedC2zG', ciBuildId: '1686734062', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'Fgt2j7QCjNedC2zG', spec: undefined, cloudServiceUrl: 'http://localhost:1234/', projectId: 'l4zuz8', batchSize: 3, tag: [], autoCancelAfterFailures: undefined } +0ms
  currents:config resolving cypress config +0ms
  currents:boot booting cypress... +0ms

from cypress-cloud.

samixchoumi avatar samixchoumi commented on July 19, 2024

Thanks @agoldis for your answer.
I updated the version to the beta and added CURRENTS_API_URL to my command (because it seem that the currents.config.js file doesn't work for me as you can see below.
My command looks like that now : CURRENTS_PROJECT_ID=xxx CURRENTS_RECORD_KEY=yyy CURRENTS_API_URL=https://localhost:1234/ DEBUG=currents:*,cypress:* npx cypress-cloud run --record --key yyy --parallel --ci-build-id $CI_PIPELINE_ID --env allure=true,configFile=dev --browser chrome

What I got now by adding the currents api url on the CLI is that :

currents:capture capturing stdout +0ms
  cypress:cli exporting Cypress module interface +0ms
  currents:cli parsed CLI flags { component: false, e2e: true, parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome' } +0ms
  currents:cli parsed run params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy' } +1ms
  currents:run run params { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy' } +0ms
  currents:run params after preprocess { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined } +0ms
  currents:config loading currents config file from '/Users/samixchoumi/IdeaProjects/projectName/currents.config.js' +0ms
  currents:config failed loading config file from: ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/samixchoumi/IdeaProjects/projectName/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/samixchoumi/IdeaProjects/projectName/currents.config.js:2:1
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:438:15)
    at loadConfigFile (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/config/config.ts:69:22)
    at getCurrentsConfig (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/config/config.ts:46:26)
    at resolveCurrentsParams (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/config/params.ts:16:26)
    at validateParams (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/config/params.ts:76:18)
    at run (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/run.ts:47:27) +4ms
  currents:config loading currents config file from '/Users/samixchoumi/IdeaProjects/projectName/currents.config.cjs' +19ms
  currents:config failed loading config file from: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/samixchoumi/IdeaProjects/projectName/currents.config.cjs' imported from /Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress-cloud/bin/cli.js +0ms
  currents:config loading currents config file from '/Users/samixchoumi/IdeaProjects/projectName/currents.config.mjs' +0ms
  currents:config failed loading config file from: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/samixchoumi/IdeaProjects/projectName/currents.config.mjs' imported from /Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress-cloud/bin/cli.js +1ms
 WARNING  Failed to load config file, falling back to the default config. Attempted locations: [
  '/Users/samixchoumi/IdeaProjects/projectName/currents.config.js',
  '/Users/samixchoumi/IdeaProjects/projectName/currents.config.cjs',
  '/Users/samixchoumi/IdeaProjects/projectName/currents.config.mjs'
]
  currents:validateParams resolving currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined } +0ms
  currents:validateParams resolving currents config file: { e2e: { batchSize: 3 }, component: { batchSize: 5 }, cloudServiceUrl: 'https://cy.currents.dev' } +0ms
  currents:validateParams validating currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined, cloudServiceUrl: 'https://localhost:1234/', projectId: 'xxx', batchSize: 3 } +0ms
  currents:validateParams validated currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined, cloudServiceUrl: 'https://localhost:1234/', projectId: 'xxx', batchSize: 3, tag: [], autoCancelAfterFailures: undefined } +1ms
  currents:config resolving cypress config +2ms
  currents:boot booting cypress... +0ms
...
[lot of line]
...
Discovered 1 spec files
Tags: false; Group: false; Parallel: true; Batch Size: 3
Connecting to cloud orchestration service...
  currents:ci detected CI provider: null +0ms
  currents:ci detected CI params: {} +0ms
  currents:ci git commit existing info +30ms
  currents:ci {
  currents:ci   branch: 'feature/update_sorry_cypress_to_cypress-cloud',
  currents:ci   remoteOrigin: '[email protected]:project/qat/projectName.git',
  currents:ci   authorEmail: '[email protected]',
  currents:ci   authorName: 'samixchoumi',
  currents:ci   message: 'Update cypress-cloud config\n',
  currents:ci   sha: '73ca7974b08a93953bd176668f49e7bb303c30da'
  currents:ci } +0ms
  currents:ci commit info from provider environment variables: {} +0ms
  currents:ci combined git and environment variables from provider +0ms
  currents:ci {
  currents:ci   branch: 'feature/update_sorry_cypress_to_cypress-cloud',
  currents:ci   remoteOrigin: '[email protected]:project/qat/projectName.git',
  currents:ci   authorEmail: '[email protected]',
  currents:ci   authorName: 'samixchoumi',
  currents:ci   message: 'Update cypress-cloud config\n',
  currents:ci   sha: '73ca7974b08a93953bd176668f49e7bb303c30da'
  currents:ci } +0ms
  currents:api network request: { method: 'post', url: '/runs', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'x-cypress-request-attempt': 0, 'x-cypress-version': '12.13.0', 'x-ccy-version': '1.8.0-beta.5' }, data: { ci: { params: {}, provider: null }, specs: [ 'cypress/integration/Spec/AScenario.feature' ], commit: { branch: 'feature/update_sorry_cypress_to_cypress-cloud', remoteOrigin: '[email protected]:project/qat/projectName.git', authorEmail: '[email protected]', authorName: 'samixchoumi', message: 'Update cypress-cloud config\n', sha: '73ca7974b08a93953bd176668f49e7bb303c30da' }, group: undefined, platform: { osName: 'darwin', osVersion: '22.5.0', osCpus: [Array], osMemory: [Object], browserName: 'Chrome', browserVersion: '114.0.5735.106' }, parallel: true, ciBuildId: '--env', projectId: 'xxx', recordKey: 'yyy', specPattern: [ './cypress/integration/**/*.feature' ], tags: [], testingType: 'e2e', batchSize: 3, autoCancelAfterFailures: undefined } } +0ms
 ERROR  write EPROTO 009E35EB01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:

from cypress-cloud.

samixchoumi avatar samixchoumi commented on July 19, 2024

Hello @agoldis, hope you're fine.
So I updated it like that :

export const projectId = 'yyy';
export const recordKey = 'xxx';
// Sorry Cypress users - set the director service URL
export const cloudServiceUrl = 'https://localhost:1234/';

(Maybe add this example for ESM syntax cases on the README ?)
I launch the command like that :
DEBUG=currents:*,cypress:* npx cypress-cloud run --record --key yyy --parallel --ci-build-id $CI_PIPELINE_ID --env allure=true,configFile=dev --browser chrome
It seem to work better but their is an error when booting :

currents:capture capturing stdout +0ms
  cypress:cli exporting Cypress module interface +0ms
  currents:cli parsed CLI flags { component: false, e2e: true, parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome' } +0ms
  currents:cli parsed run params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy' } +1ms
  currents:run run params { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy' } +0ms
  currents:run params after preprocess { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined } +0ms
  currents:config loading currents config file from '/Users/samixchoumi/IdeaProjects/projectName/currents.config.js' +0ms
  currents:config loaded currents config from '/Users/samixchoumi/IdeaProjects/projectName/currents.config.js'
  currents:config {
  currents:config   e2e: { batchSize: 3 },
  currents:config   component: { batchSize: 5 },
  currents:config   cloudServiceUrl: 'https://localhost:1234/',
  currents:config   projectId: 'yyy',
  currents:config   recordKey: 'xxx'
  currents:config } +3ms
  currents:validateParams resolving currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined } +0ms
  currents:validateParams resolving currents config file: { e2e: { batchSize: 3 }, component: { batchSize: 5 }, cloudServiceUrl: 'https://localhost:1234/', projectId: 'yyy', recordKey: 'xxx' } +0ms
  currents:validateParams validating currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined, cloudServiceUrl: 'https://localhost:1234/', projectId: 'yyy', batchSize: 3 } +0ms
  currents:validateParams validated currents params: { parallel: true, record: true, headed: false, key: 'yyy', ciBuildId: '--env', browser: 'chrome', config: undefined, env: undefined, reporterOptions: undefined, testingType: 'e2e', recordKey: 'yyy', spec: undefined, cloudServiceUrl: 'https://localhost:1234/', projectId: 'yyy', batchSize: 3, tag: [], autoCancelAfterFailures: undefined } +0ms
  currents:config resolving cypress config +1ms
  currents:boot booting cypress... +0ms
  currents:boot cypress executable location: /Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress/bin/cypress +1ms
  currents:boot cypress bootstrap params: { browser: 'chrome', record: false, env: { currents_temp_file: '/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF', currents_debug_enabled: true } } +0ms
  currents:boot cypress bootstrap serialized params: [ '--browser', 'chrome', '--record', false, '--env', '{"currents_temp_file":"/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF","currents_debug_enabled":true}' ] +0ms
  currents:boot booting cypress with args: [ '--browser', 'chrome', '--record', false, '--env', '{"currents_temp_file":"/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF","currents_debug_enabled":true}', '--spec', 'iossipxjlm', '--e2e' ] +1ms
  currents:boot exec cypress failed (certain failures are expected): Error: Command failed with exit code 1: /Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress/bin/cypress run --browser chrome --record false --env {"currents_temp_file":"/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF","currents_debug_enabled":true} --spec iossipxjlm --e2e 2023-06-15T09:12:55.878Z cypress:cli:cli cli starts with arguments
...
[some line]

And looking at the end of the line, i have that :

cypress:server:cypress exiting with err Error: Can't run because no spec files were found.  We searched for specs matching this glob pattern:  > /Users/samixchoumi/IdeaProjects/projectName/iossipxjlm at H (<embedded>:4696:527392) at process.processTicksAndRejections (node:internal/process/task_queues:96:5) { isCypressErr: true, type: 'NO_SPECS_FOUND', details: undefined, messageMarkdown: "Can't run because `no spec files` were found.\n" + '\n' + 'We searched for specs matching this glob pattern:\n' + '\n' + '  > /Users/samixchoumi/IdeaProjects/projectName/iossipxjlm', originalError: undefined, stackWithoutMessage: '    at H (<embedded>:4696:527392)\n' + '    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)' } 2023-06-15T09:12:57.638Z cypress:server:cypress calling exit 1 2023-06-15T09:12:57.638Z cypress:server:cypress about to exit with code 1 2023-06-15T09:12:57.639Z cypress:server:browsers browsers.kill called with no active instance 2023-06-15T09:12:57.639Z cypress:proxy:http:util:prerequests metrics: { browserPreRequestsReceived: 0, proxyRequestsReceived: 0, immediatelyMatchedRequests: 0, unmatchedRequests: 0, unmatchedPreRequests: 0 } 2023-06-15T09:12:57.654Z cypress:cli child event fired { event: 'exit', code: 1, signal: null } [currents:plugin] currents plugin loaded [currents:plugin] dumping config to '/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF' [currents:plugin] config is availabe at '/var/folders/jx/0hb5g7z5519027xtjtdd7r2w0000gp/T/tmp-20114-7qhYYdbHtPQF' Can't run because no spec files were found.  We searched for specs matching this glob pattern:  > /Users/samixchoumi/IdeaProjects/projectName/iossipxjlm at makeError (/Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress-cloud/node_modules/execa/lib/error.js:60:11) at handlePromise (/Users/samixchoumi/IdeaProjects/projectName/node_modules/cypress-cloud/node_modules/execa/index.js:118:26)     at processTicksAndRejections (node:internal/process/task_queues:95:5) at execCypress (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/bootstrap/bootstrap.ts:54:5) at bootCypress (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/bootstrap/bootstrap.ts:24:30) at getMergedConfig (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/config/config.ts:94:19) at run (/Users/samixchoumi/IdeaProjects/projectName/node_modules/lib/run.ts:62:18)

I don't understand where iossipxjlm come from.

And finally, at the end of the command, I got this again :

  currents:api network request: { method: 'post', url: '/runs', headers: { Accept: 'application/json, text/plain, */*', 'Content-Type': 'application/json', 'x-cypress-request-attempt': 0, 'x-cypress-version': '12.13.0', 'x-ccy-version': '1.8.0-beta.5' }, data: { ci: { params: {}, provider: null }, specs: [ 'cypress/integration/Spec/AScenario.feature', ], commit: { branch: 'feature/update_sorry_cypress_to_cypress-cloud', remoteOrigin: '[email protected]:project/qat/projectName.git', authorEmail: '[email protected]', authorName: 'samixchoumi', message: "Merge branch 'master' into feature/update_sorry_cypress_to_cypress-cloud\n", sha: '49eae51fb0ceb3d369bbe8f450df1e87c7c006fb' }, group: undefined, platform: { osName: 'darwin', osVersion: '22.5.0', osCpus: [Array], osMemory: [Object], browserName: 'Chrome', browserVersion: '114.0.5735.106' }, parallel: true, ciBuildId: '--env', projectId: 'yyy', recordKey: 'yyy', specPattern: [ './cypress/integration/**/*.feature' ], tags: [], testingType: 'e2e', batchSize: 3, autoCancelAfterFailures: undefined } } +0ms
  
 ERROR  write EPROTO 001E4CFB01000000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:355:

from cypress-cloud.

samixchoumi avatar samixchoumi commented on July 19, 2024

Found the error, changed the export const cloudServiceUrl = 'https://localhost:1234/'; to export const cloudServiceUrl = 'http://localhost:1234/';
It seem to work properly in local.

I will test using with GitLabCI

UPDATE : It works very fine (and the reporting is way better) !
Thanks.

from cypress-cloud.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.