Skip to main content

A Robot Framework library for Webpack.

Project description

https://travis-ci.org/kitconcept/robotframework-webpack.svg?branch=master Egg Status Latest Version License kitconcept

Introduction

WebpackLibrary is a Robot Framework library for Webpack. It allows to start and stop the Webpack dev server.

Installation

Install robotframework-webpack with pip:

$ pip install robotframework-webpack

Documentation

https://kitconcept.github.io/robotframework-webpack/

Usage

In order to write your first robot test, make sure that you include Selenium2Library and WebpackLibrary. Create a test.robot file with the following content:

*** Variables ***
${HOST}                 127.0.0.1
${PORT}                 8080
${BROWSER}              chrome
${SERVER}               http://${HOST}:${PORT}


*** Settings ***

Documentation   WebpackLibrary Acceptance Tests
Library         Selenium2Library  timeout=10  implicit_wait=0
Library         WebpackLibrary
Suite Setup     Start Webpack and Open Browser
Suite Teardown  Stop Webpack and Close Browser


*** Test Cases ***

Scenario: Webpack Dev Server
  Go To  ${SERVER}
  # Amend this line to check for the real content of your app. Otherwise this test will fail.
  Wait until page contains  Hello World
  Page Should Contain  Hello World


*** Keywords ***

Start Webpack and Open Browser
  Start Webpack  yarn start
  Open Browser  ${SERVER}  ${BROWSER}
  Set Window Size  1280  1024

Stop Webpack and Close Browser
  Stop Webpack
  Close Browser

Keywords

Start Webpack: Starts the webpack process. The keyword take the command line command to start Webpack (e.g. ‘yarn start’).

Start Webpack yarn start

Optional parameters are:

  • path: relative or absolute path to the path where the command should be executed.

  • check: string that the keyword looks for in the Webpack output to know that Webpack has been fully started (default is ‘Compiled successfully’).

  • debug: returns debug information

Example with all parameters set:

Start Webpack  yarn start
..  path=tests/test-create-react-app
..  check=Compiled successfully
..  debug=True

Stop Webpack: Stopps the webpack process that has been started with ‘Start Webpack’. The keyword has no parameters.

Rationale

You can start a Webpack process with standard Robot Framework keywords:

Run process  yarn run build  shell=True  cwd=${CURDIR}
Run process  yarn global add serve  shell=True  cwd=${CURDIR}
Start process  serve -s build  shell=True  cwd=${CURDIR}

You can even kill the process at the end of the test (suite):

Terminate All Processes  kill=True

Though. You will need to set a sleep statement to wait until the Webpack process is fully up and running. Since this can take a considerable amount of time it will make your test suite inefficient and hard to scale.

Robot Framework Webpack checks the output of the Webpack process until it is fully up and running. As soon as Webpack is ready, the test can continue.

Development

Project Setup:

$ virtualenv-2.7 .py27
$ source .py27/bin/activate
$ pip install -r requirements.txt
$ python setup.py develop

Run Tests:

$ .py27/bin/pybot tests

1.1.3 (2018-03-03)

Bugfixes:

  • Do not fail safe_bytes when passed string is already a bytes string. [timo]

1.1.2 (2018-03-03)

Bugfixes:

  • Fix “TypeError: a bytes-like object is required, not ‘str’” on Python 3 when calling the ‘Start Webpack’ keyword. [timo]

1.1.1 (2018-03-03)

Bugfixes:

  • Fix unicode decode error on Python 3 when Webpack process raises a runtime error. [timo]

1.1.0 (2018-03-01)

New Features:

  • Python 3 compatibility. [timo]

1.0.5 (2018-03-01)

Bugfixes:

  • Remove br from README.rst. This breaks on Pypi. [timo]

1.0.4 (2018-03-01)

Bugfixes:

  • Fix typo in ‘Stop Webpack’ keyword which breaks the entire library when it is imported. [timo]

1.0.3 (2018-03-01)

Bugfixes:

  • Raise RuntimeError when ‘Start Webpack’ and ‘Stop Webpack’ fail. [timo]

1.0.2 (2018-02-15)

Bugfixes:

  • Remove br in README which breaks the pypi page. [timo]

1.0.1 (2018-02-15)

Bugfixes:

  • Fix ReST in README. [timo]

1.0.0 (2018-02-15)

Breaking Changes:

  • Refactor ‘Start Webpack’ keyword. Remove “host”, “port”, “content_base”, “config”, “webpack_bin_path”, “debug” params. Keep “path” param. Add required “command” param and an optional “check” param. [timo]

Bugfixes:

  • Use a process group to start Webpack to being able to stop all child processes. This fixes issues with leftover child processes with create-react-app. [timo]

1.0a8 (2016-07-21)

Breaking Changes:

  • Change ROBOT_LIBRARY_SCOPE to ‘GLOBAL’. It does not make sense to fire up webpack for every single test. [timo]

1.0a7 (2016-07-19)

Bugfixes:

  • Do not log the webpack path. [timo]

1.0a6 (2016-07-18)

Bugfixes:

1.0a5 (2016-07-13)

New Features:

  • Add ‘webpack_bin_path’ param to ‘Start Webpack’ keyword. [timo]

1.0a4 (2016-07-13)

Breaking Changes:

  • Move all arguments from WebpackLibrary import to ‘Start Webpack’ keyword. [timo]

Bugfixes:

  • Remove requests from dependencies. [timo]

  • Fix package keywords. [timo]

1.0a3 (2016-07-13)

Bugfixes:

  • Fix content_base param. [timo]

  • Log OSErrors when calling webpack. [timo]

1.0a2 (2016-07-13)

New Features:

  • Add config parameter to WebpackLibrary. [timo]

1.0a1 (2016-07-12)

  • Initial release. [timo]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework-webpack-1.1.3.tar.gz (57.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page