Skip to content

Commit

Permalink
add cucumber to playground
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Feb 1, 2024
1 parent 2f197e5 commit 4f1a778
Show file tree
Hide file tree
Showing 6 changed files with 4,859 additions and 32 deletions.
8 changes: 8 additions & 0 deletions tests/Cypress/.cypress-cucumber-preprocessorrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"stepDefinitions": [
"cypress/support/steps/**/*.{js,ts}"
],
"html": {
"enabled": true
}
}
29 changes: 25 additions & 4 deletions tests/Cypress/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
const {defineConfig} = require("cypress");
import TestRailReporter from '../../index.js';

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';


export default defineConfig({

watchForFileChanges: false,

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {

const TestRailReporter = require('../../src/../index');
baseUrl: 'https://www.boxblinkracer.com',
viewportWidth: 1500,
viewportHeight: 1000,

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

async setupNodeEvents(on, config) {

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

await addCucumberPreprocessorPlugin(on, config);

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

return config
},
},
Expand Down
23 changes: 23 additions & 0 deletions tests/Cypress/cypress/e2e/blog.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Feature: Login on website

Background:
Given I am on the blog page

Rule: Happy Path

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

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


Rule: Edge Cases

Scenario : Filter for invalid tag
When I enter tag "unknown" in the URL
Then I must not see the blog
27 changes: 27 additions & 0 deletions tests/Cypress/cypress/support/steps/blog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {When, Then, Given, Before} from '@badeball/cypress-cucumber-preprocessor';


Before(() => {
// cy.request('POST', '/api/reset')
})

Given('I am on the blog page', () => {
cy.visit('/blog');
});

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) => {
cy.contains('h2', tagName);
});

Then('I enter tag {string} in the URL', (tagName) => {
cy.visit('/tags/?tag=' + tagName);
});

Then('I must not see the blog', () => {
cy.get('h2').should('not.exist');
});

Loading

0 comments on commit 4f1a778

Please sign in to comment.