2.4.0 • Published 1 year ago

prestashop_corp_tests_base_framework v2.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Tests Base Framework

This repository has the role of a base framework to use on all tests projects.

Stack

  • Playwright as a node library to automate interaction with Chromium, Firefox and WebKit.
  • Mocha BDD framework used as a test runner for some examples.
  • Cucumber-js BDD framework used as a test runner for some examples.

Browser Helper

Used as a wrapper for Playwright functions, it aims to simplify launching browsers, context and opening new tabs using environment parameters.

Here are some functions wrapped on this helper :

  • getBrowserOptions: Each browser type use different options to start, this function use the env var BROWSER to select the options to use.
  • createBrowser: When the browser type is chosen and its options are defined, this function attempt to launch the browser 3 times before throwing an error. Sometimes the browser fail or crash when started, that's why multiple attempts are done.
  • closeBrowser: After finishing the run, this function is called to destroy all browser instances or temporary files used on the run.
  • createContext: A browser could have different contexts depending on the platform to test on, this function simplify the use.
  • closeContext: After finishing a scenario, this function is called to destroy all instances created by the context.
  • addTab: To test on a browser instance, we need a tab to perform action on, this function add a new tab and return it on the test.
  • closeTab: After finishing work on a tab (and we have more than one tab), this function could used to close it.

Environment parameters

To properly use the helper, you should use the environment parameters to set the global ones.

Browser options

ParameterDescription
PLATFORMPlatform to run tests on desktop or mobile (default to desktop)
BROWSERSpecific browser to launch for tests (default to chromium)
HEADLESSBoolean to run tests in headless mode or not (default to true)
SLOW_MOInteger to slow down Playwright operations by the specified amount of milliseconds (default to 5 milliseconds)
ACCEPT_DOWNLOADSBoolean to accept downloads on a run (default to true)

Context options

ParameterDescription
WIDTHWidth size of the browser interface to open (default to 1680)
HEIGHTHeight size of the browser interface to open (default to 900)
LOCALESpecific language of the browser language (default to fr-FR)
DEVICEDevice to run test on if using mobile platform (default to null)

Tests parameters

ParameterDescription
URLUrl to open for tests (default to null)

Examples

A small example was done to test the browser helper, the scenario of the test is:

  • Go to Addons page
  • Go to First Visit page using the menu

Before running examples, dependencies must be installed.

npm install

Mocha

A Test using mocha was added using utils/mochaSetup, the example could be found on examples/mocha

To run mocha tests :

# For Desktop
URL='yourURL' npm run test:mocha:desktop

# For Mobile
BROWSER='chromium' PLATFORM='mobile' DEVICE='Pixel 2' URL='yourURL' npm run test:mocha:mobile

Cucumber

A Test using cucumber was added using utils/cucumberSetup, the example could be found on examples/cucumber

To run cucumber tests :

# For Desktop
URL='yourURL' npm run test:cucumber:desktop

# For Mobile
BROWSER='chromium' PLATFORM='mobile' DEVICE='Pixel 2' URL='yourURL' npm run test:cucumber:mobile
2.4.0

1 year ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.6

2 years ago

2.0.1

2 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago