Cypress 10 vs Cucumber vs Esbuild compatibility - cypress

I used Cypress 10 for a while with Cucumber preprocessor. Everything worked without issues. Today I updated Cypress to the latest version 10.7.0 and also #badeball/cypress-cucumber-preprocessor to 12.2.0. I have there also #bahmutov/cypress-esbuild-preprocessor 2.1.3
In my cypress.config.js file I have:
e2e: {
baseUrl: 'http://localhost:4200',
specPattern: 'cypress/e2e/features',
setupNodeEvents(on, config) {
const createEsbuildPlugin =
require('#badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin
const createBundler = require('#bahmutov/cypress-esbuild-preprocessor')
require('#badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin
on('file:preprocessor', createBundler({
plugins: [createEsbuildPlugin(config)],
}));
}
},
But now, when I start Cypress test runner, all the test are still there (all feature files), but after I click on ANY test case, I have this error:
Error: Build failed with 1 error:
node_modules/common-ancestor-path/index.js:17:37: ERROR: [plugin: feature] Reduce of empty array with no initial value
at failureErrorWithLog (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1605:15)
at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1251:28
at runOnEndCallbacks (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1034:63)
at buildResponseToResult (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1249:7)
at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1358:14
at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:666:9
at handleIncomingPacket (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:763:9)
at Socket.readFromStdout (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:632:7)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at Readable.push (node:internal/streams/readable:234:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)
And also Cypress says: No tests found. Cypress could not detect tests in this file.
Seems the issue is with esbuild, but not sure. I tried to downgrade the cucumber preprocessor, then it is working again.
Seems it is a compatibility problem between cucumber and esbuild.
Each library is managed by someone else, they do not cooperate, so I am really thinking to stop using Cucumber, but only pure Cypress.

Related

Nuxtjs - Nuxt/Image module having issues on deployment

Im building a static page in nuxtjs. I added the module nuxt/image and set it up according to the instructions in the documentation. (static with self hosted images)
ssr:true,
target: 'statics",
buildModules: [
// https://go.nuxtjs.dev/vuetify
'#nuxtjs/vuetify',
//https://image.nuxtjs.org
'#nuxt/image'
],
<nuxt-link :to="localePath('/')">
<nuxt-img
id="header-logo"
format="webp"
src="/logos/logo.png">
</nuxt-img>
</nuxt-link>
When i run npm run dev the project compiles but then the development server exists without any errors.
When I deploy it to the server through github actions the action breaks and exits on nuxt generate with the exit code: /home/githubaction/actions-runner/workspace/_temp/eb47b4c6-6c0d-42cc-[9](https://github.com/xxxxxx/xxxxx/runs/6722739489?check_suite_focus=true#step:9:10)019-dca85b061dda.sh: line 1: 17085 Segmentation fault npm run generate Error: Process completed with exit code 139.
Any idea why is that?
Update
I downgraded from version 0.6.2 to 0.6.0 and this seems to resolve the issue.

Error Running Mocha Unit Tests on Vue Project With GraphQL

Problem
I'm trying to add a GraphQL client to an existing Vue3 project though it is causing the Mocha tests to fail. Running yarn test:unit results in the following error:
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
Error: Cannot find module './version.mjs'
Require stack:
- /home/chris/Projects/bottomtime/web-vue-gql/dist/js/main.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mocha/lib/mocha.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mocha/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/argsParser/parseArgv/mocha/parseMochaArgs.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/argsParser/parseArgv/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/bin/mochapack
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function._resolveFilename (/home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/src/util/registerRequireHook.ts:21:34)
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 Module.<anonymous> (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/node_modules/graphql/index.mjs:29:1)
at __webpack_require__ (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/webpack/bootstrap:19:1)
at Object.defineProperty.value (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/src/index.ts:1:1)
at __webpack_require__ (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/webpack/bootstrap:19:1)
at Object.defineProperty.value (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/node_modules/vue-loader/dist/index.js:3:1)
[=========================] 100% (completed)
ERROR Error: mochapack exited with code 1.
Error: mochapack exited with code 1.
at ChildProcess.<anonymous> (/home/chris/Projects/bottomtime/web-vue-gql/node_modules/#vue/cli-plugin-unit-mocha/index.js:86:18)
at ChildProcess.emit (node:events:539:35)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
error Command failed with exit code 1.
Steps to Reproduce
Use the Vue CLI to scaffold a new project. (vue create project-name). For the options select "Manually select features", then enable all of the plugins, choose Vue v3.x, and choose Mocha + Chai as the unit test framework. (For all of the other questions you can just select the default.)
Once the project is scaffolded, cd into the directory and install GraphQL: yarn add graphql graphql-tag.
Add a query definition to any of the src/ files that would be loaded when the tests run. The problem specifically arises when using the gql function from the graphql-tag package. (You can grab my copy/paste-friendly example below!)
Run yarn test:unit and behold the above error.
Example GQL Code That Would Trigger the Failure
import { gql } from "graphql-tag";
gql`
query SomeQuery {
getCurrentUser {
username
}
}
`;
Notes
I've tried replacing Mocha/Chai w/ Jest to see if the problem persisted. It worked fine under Jest. That said, I'm adding GraphQL to an existing project and porting all of the tests to Jest is not exactly a great option.

Can not deploy my contract on ganache-cli using ETH mainnet fork

I used ganache-cli in combination with my Infura key to fork ETH mainnet so I could use the Uniswap router in my development environment:
ganache-cli --fork https://mainnet.infura.io/v3/<mykeyhere>
This starts my local ganache blockchain without any errors. However when I deploy my contract with truffle:
truffle(development)> deploy
I keep getting the following error:
Compiling your contracts...
===========================
✓ Fetching solc version list from solc-bin. Attempt #1
✓ Fetching solc version list from solc-bin. Attempt #1
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/MollyCoin.sol
> Artifacts written to /home/dogperson/Code/MollyCoin/build/contracts
> Compiled successfully using:
- solc: 0.6.12+commit.27d51765.Emscripten.clang
UnhandledRejections detected
Promise {
<rejected> CodedError: Given input "NaN" is not a number.
at /home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:174:23
at process.promise (internal/process/task_queues.js:97:5)
at ProviderHandler.queueRequest (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:178:36)
at ProviderHandler.request (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/provider-handler.js:58:9)
at earliestBlock (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/persistent-cache/helpers.js:149:5)
at previousClosestAncestor (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/persistent-cache/helpers.js:77:19)
at PersistentCache.cache [as initialize] (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/persistent-cache/persistent-cache.js:142:47)
at Fork.cache [as initCache] (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/fork.js:209:21)
at Fork.fallback [as initialize] (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/fork.js:206:13)
at Blockchain.async [as initialize] (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/blockchain.js:629:22)
at EthereumProvider.async [as initialize] (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/provider.js:195:5)
at Connector.connect (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/connector.js:49:5) {
code: -32000
}
} CodedError: Given input "NaN" is not a number.
at /home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:174:23
at process.promise (internal/process/task_queues.js:97:5)
at ProviderHandler.queueRequest (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/base-handler.js:178:36)
at ProviderHandler.request (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/handlers/provider-handler.js:58:9)
at earliestBlock (/home/dogperson/.nvm/versions/node/v12.22.9/lib/node_modules/truffle/node_modules/ganache/dist/node/webpack:/Ganache/chains/ethereum/ethereum/lib/src/forking/persistent-cache/helpers.js
The contract deploys just fine if I run ganache-cli without --fork. Also if I connect Remix to my forked ganache-cli through Metamask, I am also able to deploy and interact with the contract just fine, which makes me believe that the issue might be with truffle.
Extra info:
Truffle version: 5.5.13
Truffle config file
I tried to do the same thing as you and encountered the same error.
After some research I believe the issue is that ganache is read-only when used to fork mainnet (or any testnet). You can't make any transactions. Only calls.
I was able to achieve the objective by using Hardhat instead of ganache.
First I installed hardhat and initialized the sample project:
https://hardhat.org/guides/project-setup.html
Then I ran hardhat with:
npx hardhat node --fork "https://mainnet.infura.io/v3/<ACCOUNT>"
Then I ran "truffle console" in a separate terminal window, with the following lines in truffle-config.js:
const HDWalletProvider = require('#truffle/hdwallet-provider');
const mnemonic = "test test test test test test test test test test test junk";
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
provider: () => new HDWalletProvider(mnemonic, "http://127.0.0.1:8545"),
}
}
}
The mnemonic I used is "test test test test test test test test test test test junk" because that is Hardhat's default mnemonic and I was not immediately able to figure out how to configure Hardhat with a different mnemonic.
Before running the truffle console, remember to install the hdwalletprovider npm package in your truffle directory: https://www.npmjs.com/package/#truffle/hdwallet-provider
At this point I have a running truffle console connected to local hardhat process which is connected to infura. I can make transactions to deploy and interact with contracts.
Hope this helps, and good luck.

Cannot run in production mode

I have a donejs application and its running ok in development mode donejs develop, but when I run it in production mode:
donejs build
donejs deploy (to firebase)
NODE_ENV=production donejs start
it will not start and show an error (see CODE A)
This file: file:my-app/dist/bundles/my-app/index.js:704 corresponds to JQuery 3.x and its not a dependency of the project itself but a dependency of can-connect-feathers (https://github.com/canjs/can-connect-feathers). In fact in index.js there is also included JQuery 2.x what makes me think there might be some sort of incompatibility among them.
I already tried changing the project's dependency to JQuery 3.x but didn't help. Actually it will make even donejs develop fail (see CODE B).
I also tried the following:
cd my-app/node_modules/steal
npm install
but didn't help, another error appears and finally tried cd my-app/node_modules/can && npm install but that end up in multiple errors.
I'm using:
donejs#0.9.2
node#4.6.2
npm#2.15.11
can-connect-feathers#1.2.1
CODE A
NODE_ENV=production donejs start
my-app#0.0.0 start my-app
done-serve --proxy http://localhost:3030 --port 8080
done-serve starting on http://localhost:8080
Potentially unhandled rejection [5] TypeError: Error loading "package.json!npm" at file:my-app/package.json
Error loading "bundles/my-app/index" at file:my-app/dist/bundles/my-app/index.js
Error evaluating file:my-app/dist/bundles/my-app/index.js
Cannot read property 'createElement' of undefined
at i (file:my-app/dist/bundles/my-app/index.js:704:20)
at file:my-app/dist/bundles/my-app/index.js:1039:2881
at file:my-app/dist/bundles/my-app/index.js:1039:3580
at file:my-app/dist/bundles/my-app/index.js:268:21
at file:my-app/dist/bundles/my-app/index.js:268:27
at Object.exports.runInThisContext (vm.js:54:17)
at doEval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:2059:10)
at __eval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1976:7)
at Loader.exec [as __exec] (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:339:5)
at Loader.loader.instantiate (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1517:16)
CODE B
donejs develop
my-app#0.0.0 develop my-app
done-serve --develop --proxy http://localhost:3030 --port 8080
done-serve starting on http://localhost:8080
Potentially unhandled rejection [8] Error: Error loading "my-app#0.0.0#index.stache!done-autorender#0.8.0#autorender" at <unknown>
Error loading "can#2.3.27#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js
Error loading "can#2.3.27#util/jquery/jquery" from "done-autorender#0.8.0#autorender" at file:my-app/node_modules/done-autorender/src/autorender.js
Did not find ./node_modules/can/node_modules/jquery/package.json
at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11)
at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33
at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30)
at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4)
at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4)
at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13)
at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19)
at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9)
at nextTickCallbackWith0Args (node.js:436:9)
at process._tickCallback (node.js:365:13)
Potentially unhandled rejection [16] Error: Error loading "can#2.3.27#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js
Error loading "can#2.3.27#util/jquery/jquery" from "my-app#0.0.0#index.stache!done-autorender#0.8.0#autorender" at file:my-app/src/index.stache
Did not find ./node_modules/can/node_modules/jquery/package.json
at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11)
at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33
at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30)
at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4)
at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4)
at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13)
at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19)
at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9)
at nextTickCallbackWith0Args (node.js:436:9)
at process._tickCallback (node.js:365:13)
If the double jQuery installation is the issue, it should be resolved by version 2.0.0, which is exactly the same as the 1.0 version, but requires that you pass in a jQuery package as the jquery option. So, in addition to whatever else you had in your can-connect-feathers config, you'll need to provide the jquery option:
import $ from 'jquery'
import Feathers from 'can-connect-feathers';
new Feathers({
jquery: $
});

Protractor + Jasmine 2

I have config and specs files at shared folder of remote server. I run tests from local machine via console:
C:\Users\User>protractor \remoteServer\AutoSPA\config\protractor.conf.js
With jasmine framework all works good, but if I set framework: 'jasmine2' in protractor.conf.js tests don`t run:
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://10.17.175.168:50910/wd/hub
Started
No specs found
Finished in 0.001 seconds
Uncaught exception: Error while waiting for Protractor to sync with the page: "angular could not be found on the window"
[launcher] Process exited with error code 1
EXAMPLE:
conf.js:
exports.config = {
specs: ['./test.js'],
capabilities : {'browserName' : 'chrome'},
framework: 'jasmine2',
jasmineNodeOpts: {showColors: true}
};
test.js in the same folder:
describe("test", function(){
it("navigate", function(){
browser.get("https://angularjs.org/")
})
});
if it's local folder it works correctly, but if it's remote folder it doesn't find spec test.js.
I investigated and debug a little bit more and found out that Jasmine 1.3 used FS and Path for specs search, but Jasmine 2 used GLOB. Glob doesn't work with remote paths.

Resources