1.0.0-alpha.55 • Published 2 years ago

tees-environment v1.0.0-alpha.55

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

tees

Travis npm

tees is a complex of E2E test framework, it's based on jest as test runner.

Contents

Getting Started

  1. Initialize tees by cli:
npx tees init yourProjectName
  1. Tees will ask you a few questions and will create a basic configuration file and an example file. Press Enter key to choose the default configuration.
  2. Running from the command line, there is a folder "yourProjectName" under the current path:
cd yourProjectName

Run yarn install to install the necessary dependencies. It will take you several minutes.

yarn install

Run your E2E case:

npx tees run ./src/example.spec.js

Additional Configuration

Based on your project, there are several things need to config in e2e.config.js file. Add params in e2e.config.js, such as the project name, the type of your project.

module.exports  = {
  params: {
    projects: {
      //project name
      'example': {
        //uri or extension
        type: 'uri',
        //if your project is an extension, you need to add source path
        location: 'https://cn.bing.com/',
      }
    }
  },
  //...
};

Change the selectorLabel to what you are using, eg. class, id, or any other tag name.

module.exports  = {
  selectorLabel: 'class',
  //...
};

The default execution timeout for each test case is 2 minutes. If you want to change it to 20 minutes, you can add timeout in e2e.config.

module.exports  = {
  timeout: 1000  *  60  *  20,
  //...
};

Advanced Guides

CLI usage:

A simplest command can be: npx tees run yourTestFilePath

Use CLI params to control the test you are running:

ReferenceShort keyParamsdefault
--params-P-P {}None
--drivers-D-D {drivers}all drivers
--sandbox-S-Sdisable
--debugger-X-Xdisable
--headless-H-Hdisable
--exclude-E-E {filePath}disable
--verbose-A-Afalse
--retry-T-T {retryNumber}0
--report-R-Rdisable
--testerCLI-C-Cdisable
params

Run all cases which met all these params.

-P '{brands:["rc"],levels:["p0","p1"],tags:[["widgets"]]}'
drivers

Run case on specific driver

-D puppeteer

or use ',' to split difference drivers

-D puppeteer,chrome

supported drivers:

  1. puppeteer
  2. chrome
  3. firefox
  4. edge
  5. ie
  6. safari
  7. enyzme
sandbox

With sandbox mode, every case will start a totally new driver. Without sandbox mode, every run will only start a driver.

debugger

With debugger mode, some additional debug message will output. Default OFF.

headless

Headless default OFF.

exclude

Use exclude to ignore some unnecessary path.

-E ./node_modules/

to ignore more than one path

-E ./node_modules/ ./__temp__/
verbose

Enable verbose to get more imformation when debugging.

retry

Rerun case when there are some error occur. The default value of retry time is 0. The maximum retry times is 10.

-T 3
reporter

Enable reporter will push your console output to an on-line web.

testerCLI

Jest CLI. Pass params to jest via this testerCLI.

-C '--findRelatedTests path/to/fileA.js path/to/fileB.js'

Note: And you can append all these commands together.

The command below will run test file 1 and 2 in puppeteer on sandbox and headless mode. Example:

npx tees run yourTestFilePath1 yourTestFilePath2 -D puppeteer -S -H

E2E config

APIs Reference

Test CLI

ReferenceDescriptiontypedefault
--paramsRun E2E test case with some params filtering.objectNone
--sandboxRun E2E test case with 'sandbox' mode.disable
--debuggerRun E2E test case with 'debugger' mode.disable
--headlessRun E2E test case with 'headless' mode.disable
--excludeRun E2E test case exclude some files.disable
--verboseRun E2E test case with verbose log.false
--retryRun E2E test case with retry times.0

Project Config

ReferenceDescriptiontype
lookupConfigLook up executive config from this config file.function
paramsSetting project basic information.object

Test Drivers

Driver APIs
ReferenceDescriptionarguments
gotoCurrent page goto a new page with a url.(config)
clearClear the value of this element.(selector, options)
newPageCreate a new page in a default browser context.()
closePageCloses the current window.()
Query APIs
ReferenceDescriptionarguments
getTextGet text from a selector.(selector, options)
gotoCurrent page goto a new page with a url.(config)
clickleft-click with the mouse.(selector, options)
typeEnter a value on the selector.(selector, value, options)
waitForSelectorWait for the selector to appear in page.(selector, options)
waitForFramesWait for the iframes to appear in page and return a frame.(frameSelector)
screenshotTakes a screenshot of the current page.(path)
executeExecutes JavaScript in sandbox env.(...args)

Test Hooks

ReferenceDescriptioncallback arguments
driver.addAfterHookAfter each case ends.-

example:

context.driver.addAfterHook(async () => {
  await process.exec(Logout);
});

Benchmark Results

// device and environmental information

Driverscasesthreadssandboxperformancestability
puppeteer/Firefox/Chrome/Safari160011312.125s
puppeteer400896.44s
puppeteer4001237.614s
puppeteer4008289.44s
Chrome4008103.665s
Firefox4008415.726s
puppeteer/Firefox/Chrome12008630.503s⚠️
Safari4008-
Enzyme4001374.998s
Enzyme4008149.882s
Enzyme4001-

Chrome is selenium webdriver's Chrome. Selenium webdriver multithreading operation is not stable. Selenium Webdriver Safari does not support multithreading. Enzyme does not support non-sandbox mode(Default forced sandbox mode).

Contribution Guide

Read our contribution guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Tees.

License

Tees is MIT licensed.

1.0.0-alpha.55

2 years ago

1.0.0-alpha.54

5 years ago

1.0.0-alpha.53

5 years ago

1.0.0-alpha.52

5 years ago

1.0.0-alpha.51

5 years ago

1.0.0-alpha.49

5 years ago

1.0.0-alpha.48

5 years ago

1.0.0-alpha.47

5 years ago

1.0.0-alpha.46

5 years ago

1.0.0-alpha.45

5 years ago

1.0.0-alpha.44

5 years ago

1.0.0-alpha.43

5 years ago

1.0.0-alpha.41

5 years ago

1.0.0-alpha.39

5 years ago

1.0.0-alpha.37

5 years ago

1.0.0-alpha.36

5 years ago

1.0.0-alpha.33

5 years ago

1.0.0-alpha.31

5 years ago

1.0.0-alpha.30

5 years ago

1.0.0-alpha.28

5 years ago

1.0.0-alpha.27

5 years ago

1.0.0-alpha.26

5 years ago

1.0.0-alpha.25

5 years ago

1.0.0-alpha.24

5 years ago

1.0.0-alpha.23

5 years ago

1.0.0-alpha.22

5 years ago

1.0.0-alpha.21

5 years ago

1.0.0-alpha.20

5 years ago

1.0.0-alpha.18

5 years ago

1.0.0-alpha.15

5 years ago

1.0.0-alpha.14

5 years ago

1.0.0-alpha.11

5 years ago

1.0.0-alpha.10

5 years ago

1.0.0-alpha.9

5 years ago

1.0.0-alpha.8

5 years ago

1.0.0-alpha.7

5 years ago

1.0.0-alpha.6

5 years ago

1.0.0-alpha.5

5 years ago

1.0.0-alpha.4

5 years ago

1.0.0-alpha.3

5 years ago

1.0.0-alpha.2

5 years ago

1.0.0-alpha.1

5 years ago