The error below showing after executing in jenkins:
`Your configFile threw an error from: /var/lib/jenkins/workspace/PluginsUI/cypress.config.js
The error was thrown while executing your e2e.setupNodeEvents() function:
Error: Cannot find module 'node-xlsx'
Require stack:
/var/lib/jenkins/workspace/PluginsUI/cypress/plugins/index.js
/var/lib/jenkins/workspace/PluginsUI/cypress.config.js
/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_require_async_child.js
/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/require_async_child.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/var/lib/jenkins/workspace/PluginsUI/cypress/plugins/index.js:26:16)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at setupNodeEvents (/var/lib/jenkins/workspace/PluginsUI/cypress.config.js:11:14)
at /var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:118:14
at tryCatcher (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
at RunPlugins.load (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:115:9)
at RunPlugins.runSetupNodeEvents (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_plugins.js:276:10)
at EventEmitter. (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/child/run_require_async_child.js:185:22)
at EventEmitter.emit (node:events:513:28)
at process. (/var/lib/jenkins/.cache/Cypress/12.4.1/Cypress/resources/app/node_modules/#packages/server/lib/plugins/util.js:33:22)
at process.emit (node:events:513:28)
at emit (node:internal/child_process:939:14)`
I'm trying to execute the test case in cypress on jenkins pipelin configuration:
pipeline{
agent any
parameters{
string(name: 'SPEC', defaultValue: "cypress/e2e/1.Gateway/MqttGateway.cy.js", description: "Enter the script path that you want to execute")
choice(name: 'BROWSER', choices: ['chrome', 'edge', 'firefox'], description: "Choose the browser where you want to execute your scripts")
}
options{
ansiColor('xterm')
}
stages{
stage('Building'){
steps{
echo "Building the application"
}
}
stage('Testing'){
steps{
sh "npm i"
sh "npx cypress run --browser ${BROWSER} --spec ${SPEC}"
}
}
stage('Deploying'){
steps{
echo "Deploy the application"
}
}
}
post{
always{
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'cypress/report', reportFiles: 'index.html', reportName: 'HTML Report', reportTitles: '', useWrapperFileDirectly: true])
}
}
}
Related
I've already installed cypress and I once successfully open it and run some example test cases. I don't know why when I try to open it again with command npx cypress open in vscode it says
Cypress Configuration Error
This is the stack trace:
Error: Cannot find module 'cypress'
Require stack:
- C:\Users\janna\Documents\Miftah's folder\Learn\Cypress\gitRepo\ngx-cypress-test\cypress.config.js
- C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js
- C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\require_async_child.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#cspotcode\source-map-support\source-map-support.js:679:30)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\janna\Documents\Miftah's folder\Learn\Cypress\gitRepo\ngx-cypress-test\cypress.config.js:1:26)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at loadFile (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js:89:14)
at EventEmitter. (C:\Users\janna\AppData\Local\Cypress\Cache\10.6.0\Cypress\resources\app\node_modules\#packages\server\lib\plugins\child\run_require_async_child.js:116:38)
at EventEmitter.emit (node:events:527:28)
at EventEmitter.emit (node:domain:475:12)
You can fix that file with watchForFileChanges: false,
const { defineConfig } = require("cypress");
module.exports = defineConfig({
e2e: {
watchForFileChanges: false,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
So when I run this
ts-node C:\Users\ras zebi\Desktop\solana boobs\metaplex-master\js\packages\cli\src\candy-machine-v-cli.ts upload -e devnet -k C:\Users\ras zebi\Desktop\solana boobs\keypair\my-keypair.json -cp C:\Users\ras zebi\Desktop\solana boobs\metaplex-master\js\packages\cli\example-candy-machine-upload-config.json C:\Users\ras zebi\Desktop\solana boobs\metaplex-master\my assets
I get this
Error: Cannot find module './ras'
Require stack:
- C:\Users\imaginaryUncacheableRequireResolveScript
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.resolve (node:internal/modules/cjs/helpers:108:19)
at requireResolveNonCached (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:496:16)
at getProjectSearchDir (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:466:40)
at phase3 (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:268:27)
at bootstrap (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:44:30)
at main (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:32:12)
at Object.<anonymous> (C:\Users\ras zebi\AppData\Roaming\npm\node_modules\ts-node\dist\bin.js:526:5)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\\Users\\imaginaryUncacheableRequireResolveScript' ]
What can I try to fix this?
I want to run WebdriverIO + Mocha tests from the WebStorm gutter (the green triangle icons on the left side, by the line numbers).
But when I press run triangle - error occurred:
/Users/ilyubin/.nvm/versions/node/v10.15.0/bin/node /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/bin/_mocha --ui bdd --reporter /Applications/WebStorm.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/test/specs/catalog/not.found.page.spec.js --grep "^Тесты страницы ошибок Поиск несуществующего запроса$"
/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/test/specs/catalog/not.found.page.spec.js:1
(function (exports, require, module, __filename, __dirname) { import {expect} from 'chai';
^
SyntaxError: Unexpected token {
at new Script (vm.js:79:7)
at createScript (vm.js:251:10)
at Object.runInThisContext (vm.js:303:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/mocha.js:324:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/mocha.js:321:14)
at Mocha.run (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/mocha.js:763:10)
at Object.exports.singleRun (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/cli/run-helpers.js:196:16)
at exports.runMocha (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/cli/run-helpers.js:291:13)
at Object.exports.handler.argv [as handler] (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/cli/run.js:292:3)
at Object.runCommand (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/node_modules/yargs/yargs.js:1072:28)
at Object.parse (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/lib/cli/cli.js:62:6)
at Object.<anonymous> (/Users/ilyubin/git/ozon.ru/packages/ozon.ru-ui-tests/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
How to run WebdriverIO tests from WebStorm?
My versions:
WebStorm 2018.3.3
Build #WS-183.5153.33, built on January 9, 2019
JRE: 1.8.0_152-release-1343-b26 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.2
➜ ~ node -v
v10.15.0
➜ ~ mocha --version
5.2.0
My dependencies:
"dependencies": {
"#wdio/allure-reporter": "^5.4.9",
"#wdio/cli": "^5.4.13",
"#wdio/local-runner": "^5.4.13",
"#wdio/mocha-framework": "^5.4.13",
"#wdio/spec-reporter": "^5.4.3",
"#wdio/sync": "^5.4.13",
...
},
You can't run wdio specs using mocha test runner, so Mocha run configuration can't be used here. You need using Node.js run configuration instead:
Also, as you are using ES6 syntax in your tests, you have to configure wdio to use babel. See https://webdriver.io/docs/babel.html for instructions:
npm install --save-dev #babel/core #babel/cli #babel/preset-env #babel/register
in the project root folder, create a file babel.config.js:
module.exports = {
presets: [
['#babel/preset-env', {
targets: {
node: 8
}
}]
]
}
in your wdio.conf.js, set up mocha as follows;
mochaOpts: {
ui: 'bdd',
timeout: 60000,
compilers: ['js:#babel/register']
},
I have a component that loads styles like this. The css directory is somewhere else; here it is being used as a Webpack alias.
import 'css/components/PromptText';
// ...
class PromptText extends React.Component {
// ...
}
Here is my webpack.config.json:
var path = require('path');
module.exports = {
entry: './src/index.jsx',
output: {
path: 'dist',
filename: 'app.bundle.js',
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
}, {
test: /\.json/,
exclude: /node_modules/,
loader: 'json',
}, {
test: /\.scss/,
exclude: /node_modules/,
loaders: ['style', 'css', 'sass'],
}],
},
resolve: {
alias: {
css: 'css', // <-- Alias here
},
root: path.resolve(__dirname),
extensions: ['', '.js', '.jsx', '.scss'],
},
};
Now, I have a test like this for Mocha:
import PromptText from '../../src/components/PromptText';
describe('PromptText', () => {
it('should display words');
});
When Mocha imports the component, it also tries to load the CSS component. There are two problems with this:
The css directory has been aliased. Mocha needs to know where the alias points. To fix this, I have installed the babel-plugin-webpack-alias package, with the following .babelrc:
{
"presets": ["es2017", "react", "stage-0"],
"env": {
"test": {
"plugins": [
["webpack-alias", {"config": "webpack.config.js"}]
]
}
}
}
CSS can't be imported by Mocha, so it needs to be ignored. I use the ignore-styles package and invoke Mocha as mocha --compilers js:babel-core/register --require ignore-styles.
Despite having done these two things, I get the following error when trying to run tests:
(cd data && make)
make[1]: Nothing to be done for `all'.
NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register --require ignore-styles \
$(find test -type f -name 'test*.js')
module.js:341
throw err;
^
Error: Cannot find module 'css'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/src/components/PromptText.jsx:2:1)
at Module._compile (module.js:413:34)
at loader (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:146:5)
at Object.require.extensions.(anonymous function) [as .jsx] (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:156:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/test/components/testPromptText.js:2:1)
at Module._compile (module.js:413:34)
at loader (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:146:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/waleed/Workspace/js/steno/node_modules/babel-register/lib/node.js:156:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at /Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/Users/waleed/Workspace/js/steno/node_modules/mocha/lib/mocha.js:485:10)
at Object.<anonymous> (/Users/waleed/Workspace/js/steno/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:148:18)
at node.js:405:3
make: *** [test] Error 1
For some reason, the css alias isn't being resolved. However, this error only happens sometimes, unpredictably. In order to consistently recreate this error, I have to set BABEL_DISABLE_CACHE=1 in the environment.
How can I get my Mocha test to correctly import and ignore the CSS file?
In order to fix this, I switched from the babel-plugin-webpack-alias to the babel-plugin-webpack-aliases package, and update my .babelrc to use it:
{
"presets": ["es2017", "react", "stage-0"],
"env": {
"test": {
"plugins": [
["webpack-aliases", {"config": "webpack.config.js"}]
]
}
}
}
I also always run mocha with BABEL_DISABLE_CACHE=1 set in the environment. (I think this is undoing the damage that babel-plugin-webpack-alias did; it may not be necessary on every run if that package was never used.)
I'm trying to run a Protractor Test using Angular 2 and Webpack
Partial Webpack config:
resolve: {
extensions: ['', '.ts', '.js', '.scss', '.css']
},
module: {
loaders: [
// TypeScript
{ test: /\.ts$/, loader: 'ts-loader'},
// SCSS
{ test: /\.scss$/, exclude: /node_modules/, loaders: ['raw-loader', 'sass-loader']}
]
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(true)
]
My home.component.ts
import { Component, Injectable } from '#angular/core';
#Component({
selector: 'home',
styles: [require('./home.component.scss')],
template: `<h4 class="page-home">Home</h4>`
})
#Injectable()
export class Home {}
And my home.component.scss
.page-home {
color: blue;
}
And my E2E:
require('../server');
describe('App', () => {
beforeEach(() => {
browser.get('/');
});
it('should have a title', (done) => {
let subject = browser.getTitle();
subject
.then((data) => {
let result = 'test';
expect(data).toEqual(result);
done();
});
});
it('should definitely pass', () => {
expect(true).toEqual(true);
});
});
I run the server and everything comes up as expected. When I run my E2E tests I get the following error:
[14:42:47] I/hosted - Using the selenium server at http://hub.browserstack.com/wd/hub
[14:42:47] I/launcher - Running 1 instances of WebDriver
[14:43:03] E/launcher - Error: /app/src/app/home/home.component.scss:1
(function (exports, require, module, __filename, __dirname) { .page-home {
^
SyntaxError: Unexpected token .
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at home.component.ts:5:12
at Object.<anonymous> (home.component.ts:9:21)
[14:43:03] E/launcher - Process exited with error code 100
npm info lifecycle cnd-app#1.0.0~protractor: Failed to exec protractor script
npm ERR! Linux 3.19.0-59-generic
npm ERR! argv "/usr/local/bin/node" "/app/node_modules/.bin/npm" "run" "protractor"
npm ERR! node v6.2.0
npm ERR! npm v3.9.2
npm ERR! code ELIFECYCLE
npm ERR! cnd-app#1.0.0 protractor: `protractor protractor.conf.js`
npm ERR! Exit status 100
It seems like protractor uses require different than how WebPack treats it.Is there a config for this or anything I am missing?
** Update **
I am able to resolve the issue. I have a typescript register causing conflict in the protractor.conf.js.