@dennisdigital/polaris-e2etesting

1.0.1 • Public • Published

polaris-e2etesting

Tools for running user tests against our siteapps

Setup

  1. yarn add -D dennisinteractive/polaris-e2etesting

  2. Create e2e_tests folder with following structure:

mkdir e2e_tests e2e_tests/features e2e_tests/tests e2e_tests/output e2e_tests/screenshots && touch e2e_tests/output/.gitignore && echo '*\n!.gitignore' > e2e_tests/output/.gitignore

e2e_tests
│
└───features
│   │   bddtest1.feature
│   │   bddtest2.feature
│   
└───tests
│   │   test1.test.js
│   │   test2.test.js
│   
└───output
└───screenshots
  1. Create runTests.js file
const runTests = require('@dennisdigital/polaris-e2etesting');
runTests();
  1. Add "test:e2e": "node ./runTests.js" to your package.json scripts section

  2. Update the site's Dockerfile (docker/Dockerfile) to include the following after ARG BUILD_COMMAND

# Install dependencies for running Puppeteer
# https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
      --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*
  1. Ensure the siteapp's webpack config does not include the Dotenv plugin for the server bundle (it should still be used for the client bundle)

Usage

Extra config

Default codecept config can be overriden like so

const runTests = require('@dennisdigital/polaris-e2etesting');

runTests({
  extraConfig: {
    helpers: {
      TestCafe: {
        browser: 'safari',
      },
    },
    gherkin: {
      steps: [
        './e2e_tests/step_definitions/steps.js',
      ],
    },
  },
});

extraConfig will be merged with default config and override any already defined options. This allows adding extra site specific step definitions to the gherkin.steps array

Override URL

By default a local server will be spun up running the local sitecode (this assumes the code has been compiled, using either yarn build or yarn watch).

If you wish to use a specific url instead this can be overridden by passing the baseUrl parameter. In this case the local server won't run, instead the tests will just run against the url specified

const runTests = require('@dennisdigital/polaris-e2etesting');

runTests({
  baseUrl: 'https://evo.develop.coreapp.didev.co.uk',
});

Arguments

Arguments can be passed to the package.json script like so: yarn test:e2e --dev

  • yarn test:e2e --dev - shows browser when running tests

Development

To develop against polaris-e2etesting from within a siteapp (e.g. https://github.com/dennisinteractive/polaris-siteapp) do the following:

  • Clone both the polaris-e2etesting repo and the siteapp repo into their respective folders
  • In polaris-e2etesting run yarn link. This will allow it to be symlinked in other projects
  • In polaris-siteapp run yarn to install dependencies, then run yarn link polaris-e2etesting. This means that polaris-siteapp will now use your local copy of polaris-e2etesting instead of the copy in its node_modules folder, allowing you to develop against it
  • Run yarn test:e2e in polaris-siteapp to start your local version of the test runner

/@dennisdigital/polaris-e2etesting/

    Package Sidebar

    Install

    npm i @dennisdigital/polaris-e2etesting

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    84.4 kB

    Total Files

    7

    Last publish

    Collaborators

    • iliasp
    • majdanas
    • chriskinch
    • willhowlett
    • asvin