包详细信息

@mochify/driver-jsdom

yasharf34MIT1.0.0

jsdom driver for Mochify

mocha, jsdom, headless, testing

自述文件

Mochify driver for jsdom

Run tests in jsdom.

Use this driver with the Mochify CLI to run Mocha tests in jsdom, a headless web browser emulator for testing. See Mochify if you are looking for Mochify drivers for other browser testing environments.

Usage

Install the package from npm:

npm i @mochify/driver-jsdom -D

and pass it to the Mochify CLI:

mochify --driver jsdom ...

Example with options passed to the driver:

mochify --driver jsdom \
  --driver-option.url https://example.test \
  --driver-option.pretendToBeVisual false

Driver options

The driver allows the following options to be set:

  • stderr: Defines the stream the test output will be written to. Default: process.stderr.

  • strictSSL: Set to false to disable the requirement that SSL certificates be valid. Default: false.

  • pretendToBeVisual: When true, jsdom will pretend that it is rendering and displaying content. Default: true.

  • url: Run tests in the context of the given URL. Default: http://localhost.

Passing through other options to jsdom

In addition to the driver options documented above, driver-jsdom allows you to pass through all of jsdom's other constructor options, using the defaults as described here. Note that it is not possible to use a custom virtualConsole or to set the runScripts option, because the driver needs to set these itself to function correctly.