Zaista / cypress-mongodb

Cypress MongoDB plugin
MIT License
17 stars 8 forks source link

Could not resolve "crypto" and others (trying to use it with a preprocessor ) #47

Closed Deepikapatel14 closed 5 months ago

Deepikapatel14 commented 6 months ago

image

This is my e2e.js file

import './commands'; import './StepDefinition/Global'; import 'cypress-mochawesome-reporter/register'; import 'cypress-xpath'; import { addCommands } from 'cypress-mongodb/dist/index-browser'; addCommands();

This is cypress config file

const addCucumberPreprocessorPlugin = require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin; const createEsbuildPlugin = require('@badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin; const cypressmongodb = require('cypress-mongodb');

module.exports = defineConfig({ env: { mongodb: { uri: '', database: 'database_name', collection: 'collection_name' } }, setupNodeEvents(on, config) { cypressmongodb.configurePlugin(on); require('cypress-mochawesome-reporter/plugin')(on); } });

mongodb_stepdef.js

import { When, Given, Then } from '@badeball/cypress-cucumber-preprocessor'; const collection_data = {

uri: '', database: '', collection: '' } Given('It Should create new collections', () => { //create collection cy.createCollection(collection_data.collection).then((result) => { assert.strictEqual(result, 'Collection created'); }); });

mongodb.feature Feature: Testing MongoDB Integration with Cypress

Scenario: Insert data into MongoDB Given It Should create new collections

Package.json "dependencies": { "@badeball/cypress-cucumber-preprocessor": "latest", "@bahmutov/cypress-esbuild-preprocessor": "2.1.5", "@faker-js/faker": "^8.0.2", "@percy/cypress": "^3.1.2", "cypress": "^13.8.0", "cypress-mochawesome-reporter": "^3.2.2", "cypress-mongodb": "^6.2.0", "cypress-xpath": "^2.0.1", "dotenv": "^16.0.1", "esbuild": "^0.15.9", "fast-csv": "^4.3.6", "install": "^0.13.0", "mongodb": "3.6.6", "xlsx": "^0.18.5" }, "cypress-cucumber-preprocessor": { "stepDefinitions": "cypress/e2e/*//*.{js,ts}", }, "devDependencies": { "cypress-multi-reporters": "^1.6.3", "cypress-v10-preserve-cookie": "^1.2.1" } }

javier-crowdar commented 5 months ago

delete mongodb dependencie and use only cypress-mongodb this is a bug with cypress-esbuild-preprocessor

Deepikapatel14 commented 5 months ago

It worked! thanks