Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/moli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Moli Helper Tests

on:
push:
branches:
- 4.x
pull_request:
branches:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

env:
CI: true
FORCE_COLOR: 1
MOLI_VERSION: v1.1.17
MOLI_SHA256: e338cdd2ab6e3e6262117e56aba625bf6c71c44fd72ac3870bbd9c0e6c1ec351

jobs:
build:
runs-on: ubuntu-22.04
timeout-minutes: 15

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: npm install
run: npm i --force
- name: Cache Moli tarball
uses: actions/cache@v6
with:
path: ~/moli-bin/moli.tar.gz
key: moli-${{ env.MOLI_VERSION }}-x86_64-linux
- name: Download Moli
run: |
mkdir -p ~/moli-bin
if [ ! -f ~/moli-bin/moli.tar.gz ]; then
curl -sfL --retry 3 -o ~/moli-bin/moli.tar.gz https://github.com/lexmount/moli/releases/download/${MOLI_VERSION}/moli-x86_64-unknown-linux-gnu.tar.gz
fi
echo "${MOLI_SHA256} $HOME/moli-bin/moli.tar.gz" | sha256sum -c -
tar xzf ~/moli-bin/moli.tar.gz -C ~/moli-bin --strip-components=1
~/moli-bin/moli --version
- name: start test server
run: |
php -S 127.0.0.1:8000 -t test/data/app &
sleep 1
curl -sf http://127.0.0.1:8000/info > /dev/null
- name: run moli helper tests
run: |
export MOLI_PATH="$HOME/moli-bin/moli"
npm run test:unit:webbapi:moli
- name: run moli acceptance tests
run: |
export MOLI_PATH="$HOME/moli-bin/moli"
./bin/codecept.js run -c test/acceptance/codecept.Moli.js --grep @Moli --debug
2 changes: 1 addition & 1 deletion .github/workflows/webdriver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
SELENIUM_HOST: localhost
SELENIUM_PORT: 4444
- name: run unit tests
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit --reporter @testomatio/reporter/mocha
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit
timeout-minutes: 10
env:
SELENIUM_HOST: localhost
Expand Down
27 changes: 14 additions & 13 deletions Bunoshfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ const inheritedHelperDocs = {
},
Obscura: { parent: 'CDPBrowser' },
Lightpanda: { parent: 'CDPBrowser' },
Moli: { parent: 'CDPBrowser' },
Kitesurf: { parent: 'CDPBrowser', excludeConfig: ['endpoint', 'headers'] },
}

Expand Down Expand Up @@ -715,21 +716,21 @@ export async function prettier() {
* Run unit tests.
*/
export async function testUnit() {
await shell`mocha test/unit --recursive --timeout 10000 --reporter @testomatio/reporter/mocha`
await shell`mocha test/unit --recursive --timeout 10000`
}

/**
* Run REST tests.
*/
export async function testRest() {
await shell`mocha test/rest --recursive --timeout 20000 --reporter @testomatio/reporter/mocha`
await shell`mocha test/rest --recursive --timeout 20000`
}

/**
* Run runner tests.
*/
export async function testRunner() {
await shell`mocha test/runner --recursive --timeout 10000 --reporter @testomatio/reporter/mocha`
await shell`mocha test/runner --recursive --timeout 10000`
}

/**
Expand All @@ -755,28 +756,28 @@ export async function testWithMockServer() {
* Run quick Appium tests.
*/
export async function testAppiumQuick() {
await shell`mocha test/helper/Appium_test.js --grep 'quick' --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Appium_test.js --grep 'quick'`
}

/**
* Run the remaining (second) Appium tests.
*/
export async function testAppiumOther() {
await shell`mocha test/helper/Appium_test.js --grep 'second' --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Appium_test.js --grep 'second'`
}

/**
* Run quick iOS Appium tests.
*/
export async function testIosAppiumQuick() {
await shell`mocha test/helper/Appium_ios_test.js --grep 'quick' --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Appium_ios_test.js --grep 'quick'`
}

/**
* Run the remaining (second) iOS Appium tests.
*/
export async function testIosAppiumOther() {
await shell`mocha test/helper/Appium_ios_test.js --grep 'second' --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Appium_ios_test.js --grep 'second'`
}

/**
Expand All @@ -797,42 +798,42 @@ export async function testAppStop() {
* Run Playwright helper unit tests.
*/
export async function testWebapiPlaywright() {
await shell`mocha test/helper/Playwright_test.js --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Playwright_test.js`
}

/**
* Run Puppeteer helper unit tests.
*/
export async function testWebapiPuppeteer() {
await shell`mocha test/helper/Puppeteer_test.js --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Puppeteer_test.js`
}

/**
* Run WebDriver helper unit tests.
*/
export async function testWebapiWebdriver() {
await shell`mocha test/helper/WebDriver_test.js --timeout 10000 --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/WebDriver_test.js --timeout 10000`
}

/**
* Run WebDriver helper unit tests without a Selenium server.
*/
export async function testWebapiWebdriverNoSelenium() {
await shell`mocha test/helper/WebDriver.noSeleniumServer_test.js --timeout 10000 --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/WebDriver.noSeleniumServer_test.js --timeout 10000`
}

/**
* Run Expect helper unit tests.
*/
export async function testExpect() {
await shell`mocha test/helper/Expect_test.js --reporter @testomatio/reporter/mocha`
await shell`mocha test/helper/Expect_test.js`
}

/**
* Run plugin tests.
*/
export async function testPlugin() {
await shell`mocha test/plugin/plugin_test.js --reporter @testomatio/reporter/mocha`
await shell`mocha test/plugin/plugin_test.js`
}

/**
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
| 🌐 Web | WebDriver | [![WebDriver Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/webdriver.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/webdriver.yml) |
| 🌐 Web | Obscura | [![Obscura Helper Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/obscura.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/obscura.yml) |
| 🌐 Web | Lightpanda | [![Lightpanda Helper Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/lightpanda.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/lightpanda.yml) |
| 🌐 Web | Moli | [![Moli Helper Tests](https://github.com/codeceptjs/CodeceptJS/actions/workflows/moli.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/moli.yml) |
| 📱 Mobile | Appium | [![Appium Tests - Android](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appium_Android.yml/badge.svg)](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appium_Android.yml) |

# CodeceptJS [![Made in Ukraine](https://img.shields.io/badge/made_in-ukraine-ffd700.svg?labelColor=0057b7)](https://stand-with-ukraine.pp.ua)
Expand Down Expand Up @@ -46,6 +47,7 @@ CodeceptJS uses **Helper** modules to provide actions to `I` object. Currently,
- [**WebDriver**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/WebDriver.md) - uses [webdriverio](http://webdriver.io/) to run tests via WebDriver or Devtools protocol.
- [**Obscura**](https://codecept.io/helpers/Obscura) - drives the lightweight Obscura browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
- [**Lightpanda**](https://codecept.io/helpers/Lightpanda) - drives the Lightpanda headless browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
- [**Moli**](https://codecept.io/helpers/Moli) - drives the Moli headless browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
- [**Appium**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Appium.md) - for **mobile testing** with Appium
- [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library, aimed to unify testing experience for CodeceptJS framework. Detox provides a grey box testing for mobile applications, playing especially well for React Native apps.

Expand Down
57 changes: 56 additions & 1 deletion docs/alternative-browsers.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Alternative Browser Engines
# Alternative Browser Engines

::: warning Experimental
The `Obscura`, `Lightpanda` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
The `Obscura`, `Lightpanda`, `Moli` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
:::

Playwright drives full Chromium, Firefox and WebKit: the most accurate way to test what users see, at the cost of a heavy browser per worker. Alternative engines trade part of that accuracy for speed, a small footprint, or cloud scale. They are a good fit for functional tests (text appears, form submits, redirect happens, cookie is set) and a poor one for anything visual.
Expand Down Expand Up @@ -143,6 +143,61 @@ Lightpanda: {

All options: [Lightpanda helper reference](/helpers/Lightpanda).

## Moli

[Moli](https://github.com/lexmount/moli) is an open-source headless browser built in Rust for automation. It runs your app's JavaScript in V8 and computes real CSS, but skips layout and painting, so it starts fast and stays small. Visibility checks such as `seeElement` and `waitForVisible` work.

Limitations:

- No screenshots: `saveScreenshot`, failure screenshots and the `screencast` plugin do not work.
- `clickXY` does not work.
- `attachFile` uploads files without a MIME type; the server receives `application/octet-stream`.
- Links have no default color: `a` computes `color: rgb(0, 0, 0)`.

### Setup

Install Moli following the [official instructions](https://github.com/lexmount/moli#direct-installation) and put `moli` on `PATH`. Then enable the helper:

```js
// codecept.conf.js
export const config = {
helpers: {
Moli: {
url: 'http://localhost:3000',
},
},
}
```

If the binary is not on `PATH`, set `binaryPath` in the config or the `MOLI_PATH` environment variable.

### Usage

```sh
npx codeceptjs run
```

The helper starts `moli serve` on a free port before the first test and stops it after the last one. Each worker gets its own instance:

```sh
npx codeceptjs run-workers 8
```

To connect to a Moli you started yourself, set `endpoint`; the helper then never starts or stops it:

```sh
moli serve --host 127.0.0.1 --port 9222
```

```js
Moli: {
url: 'http://localhost:3000',
endpoint: 'http://127.0.0.1:9222',
}
```

All options: [Moli helper reference](/helpers/Moli).

## Kitesurf

[Kitesurf](https://blog.cloudflare.com/kitesurf/) is Cloudflare's browser running on Cloudflare Workers, with a real layout and rendering pipeline. Sessions start in about a second and nothing runs on your machine, so the number of parallel browsers is limited only by how far your suite splits.
Expand Down
Loading
Loading