GithubHelp home page GithubHelp logo

kafkaforks / codeceptjs-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sveneisenschmidt/codeceptjs-boilerplate

0.0 1.0 0.0 45 KB

CodeceptJS inside Docker, including Selenium.

Dockerfile 0.59% Makefile 26.14% JavaScript 73.28%

codeceptjs-boilerplate's Introduction

codeceptjs-boilerplate

Installation

make install

Tests

Start the Selelnium Server first so you can connect to thr VNC server beforehand. Although through container linking the Selenium Server container will be started automatically.

$ make start-selenium
Selenium VNC server is running at 0.0.0.0:59001
$ make shell
$ npm test

> [email protected] test /data
> codeceptjs run --steps

CodeceptJS v1.1.5
Using test root "/data"

Example --
 test something
 • I am on page "/?hl=en"
 • I see "Sign in"
 ✓ OK in 1193ms


  OK  | 1 passed   // 1s
# stop selenium server
$ make stop-selenium

Other

Start interactive shell

$ make shell

Start debugging via VNC

Connect with a preferred VNC client to 0.0.0.0:59001/59002, the password is secret.

$ make start-selenium
Chrome #1 VNC server is running at 0.0.0.0:59001
Chrome #2 VNC server is running at 0.0.0.0:59002

Todo

  1. Move contents to node_modules/codeceptjs/lib/chunk.js
const glob = require('glob');
const path = require('path');
const fs = require('fs');

const split = (list, size)  => {
    let sets = [];
    let chunks = list.length / size;
    let i = 0;

    while (i < chunks) {
        sets[i] = list.splice(0, size);
        i++;
    }

    return sets;
};

const find = (pattern) => {
    let files = [];

    glob.sync(pattern).forEach((file) => {
        files.push(path.resolve(file));
    });

    return files;
};

const flatten = (list) => {
    let pattern = list.join(',');
    return pattern.indexOf(',') > -1 ?  `{${pattern}}` : pattern;
};

const grep = (file, grep) => {
    const contents = fs.readFileSync(file);
    const pattern = new RegExp(`((Scenario|Feature)\(.*${grep}.*\))`, 'g'); // <- How future proof/solid is this?
    return !!pattern.exec(contents);
};

const create = (config, pattern) => {
    let files = find(pattern).filter((file) => {
        return !!config.grep ? grep(file, config.grep) : true;
    });

    const size = Math.ceil(files.length/config.chunks);
    let chunks = split(files, size);
    let chunkConfig = { ...config };

    delete chunkConfig.chunks;

    return chunks.map((chunkFiles) => {
        return { ...chunkConfig, tests: flatten(chunkFiles) }
    });
}

module.exports = {
    createChunks: create
};
  1. Patch node_modules/codeceptjs/command/run-multiple.js
// Line 12
const chunk = require('../chunk');
// ..
// Line 58
  suites.forEach((suite, index) => {
    // get suites
    const [suiteName, browser] = suite.split(':');
    const suiteConfig = configMultiple[suiteName];

    if (!suiteConfig) {
      throw new Error(`Suite ${suiteName} was not configured in "multiple" section of config`);
    }
    let pattern = config.tests || null;
    if(!suiteConfig.chunks || !Number.isFinite(suiteConfig.chunks) || !pattern) {
      return;
    }

    delete suites[index];
    chunk.createChunks(suiteConfig, pattern).forEach((suiteChunkConfig, index) => {
      let chunkSuiteName = `${suite}--chunk${index+1}`;
      configMultiple[chunkSuiteName] = suiteChunkConfig;
      suites.push(chunkSuiteName);
    });
  });

codeceptjs-boilerplate's People

Contributors

sveneisenschmidt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.