Skip to content

Commit

Permalink
MLAPB-22: Add cypress and codecept (#17)
Browse files Browse the repository at this point in the history
* Add cypress and codeceptJS

* Add axe/a11y checking to cypress and codeceptJS
  • Loading branch information
acsauk authored Aug 10, 2022
1 parent b12652d commit 8d6733c
Show file tree
Hide file tree
Showing 16 changed files with 4,244 additions and 311 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ query/s3_objects/**
**/coverage.out
**/node_modules
**/yarn-error.log
/cypress/video/*
/cypress/screenshots/*
/codecept/output/*
/web/static/*
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ WORKDIR /app

RUN mkdir -p web/static

COPY app/package.json .
COPY app/yarn.lock .
COPY package.json .
COPY yarn.lock .
RUN yarn

COPY web/assets web/assets
Expand Down
23 changes: 0 additions & 23 deletions app/package.json

This file was deleted.

286 changes: 0 additions & 286 deletions app/yarn.lock

This file was deleted.

29 changes: 29 additions & 0 deletions codecept.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');

// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

exports.config = {
tests: './codecept/scenarios/*_test.js',
output: './codecept/output',
helpers: {
Playwright: {
url: 'http://localhost:5050',
show: false,
browser: 'chromium'
},
AxeRunner: {
require: './codecept/helpers/axeRunner_helper.js'
}
},
include: {
I: './codecept/steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'app'
}
34 changes: 34 additions & 0 deletions codecept/helpers/axeRunner_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const Helper = require('@codeceptjs/helper');
const { injectAxe, checkA11y } = require('axe-playwright')

class AxeRunner extends Helper {

// before/after hooks
/**
* @protected
*/
_before() {

}

/**
* @protected
*/
_after() {
// remove if not used
}

async runAccessibilityChecks() {
const { page } = this.helpers.Playwright;
await injectAxe(page)
await checkA11y(page, null, {
detailedReport: true,
})
}
// add custom methods here
// If you need to access other helpers
// use: this.helpers['helperName']

}

module.exports = AxeRunner;
Loading

0 comments on commit 8d6733c

Please sign in to comment.