Skip to content

Commit

Permalink
improve and test cucumber integration
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Feb 1, 2024
1 parent 4e3de10 commit 02318ac
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const Reporter = require("./src/Reporter");
const Reporter = require('./src/Reporter');

module.exports = Reporter;

Expand Down
18 changes: 10 additions & 8 deletions tests/Cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import TestRailReporter from '../../index.js';
const createBundler = require('@bahmutov/cypress-esbuild-preprocessor');
const {addCucumberPreprocessorPlugin} = require('@badeball/cypress-cucumber-preprocessor');
const {createEsbuildPlugin} = require('@badeball/cypress-cucumber-preprocessor/esbuild');

import createBundler from '@bahmutov/cypress-esbuild-preprocessor';
import {addCucumberPreprocessorPlugin} from '@badeball/cypress-cucumber-preprocessor';
import {createEsbuildPlugin} from '@badeball/cypress-cucumber-preprocessor/esbuild';
import {defineConfig} from 'cypress';
const {defineConfig} = require('cypress');

const TestRailReporter = require('../../src/../index');

export default defineConfig({
module.exports = defineConfig({

watchForFileChanges: false,

Expand All @@ -18,16 +18,18 @@ export default defineConfig({

specPattern: ['cypress/e2e/**/*.feature', 'cypress/e2e/**/*.js'],

async setupNodeEvents(on, config) {
async setupNodeEvents(cypressOn, config) {

new TestRailReporter(on, config).register();
const on = require('cypress-on-fix')(cypressOn)

await addCucumberPreprocessorPlugin(on, config);

on('file:preprocessor', createBundler({
plugins: [createEsbuildPlugin(config)],
}));

new TestRailReporter(on, config).register();

return config
},
},
Expand Down
9 changes: 2 additions & 7 deletions tests/Cypress/cypress/e2e/blog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ Feature: Login on website
Rule: Happy Path

@smoke
Scenario Outline: Filter blog posts by tags
Scenario Outline: C123: Filter blog posts by tags
When I click on tag <tag>
Then I see the tag <title> as title
Then I see tag <title> as title

Examples:
| tag | title |
| DEV | Dev |
| DEVOPS | devops |


Rule: Edge Cases

Scenario: Filter for invalid tag
When I enter tag "abc" in the URL
Then I must not see the blog
2 changes: 1 addition & 1 deletion tests/Cypress/cypress/support/steps/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When(/^I click on tag (.*)$/, (tagName) => {
cy.get('.article-tags__box > [href="/tags/?tag=' + tagName.toLowerCase() + '"]').first().click();
});

Then(/^I see the tag (.*) as title$/, (tagName) => {
Then(/^I see tag (.*) as title$/, (tagName) => {
cy.contains('h2', tagName);
});

Expand Down
15 changes: 15 additions & 0 deletions tests/Cypress/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/Cypress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "cypress",
"type": "module",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand All @@ -13,5 +12,8 @@
"@badeball/cypress-cucumber-preprocessor": "^20.0.1",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"cypress": "^13.0.0"
},
"devDependencies": {
"cypress-on-fix": "^1.0.2"
}
}

0 comments on commit 02318ac

Please sign in to comment.