0.2.2 • Published 2 years ago

jest-environment-nightwatch v0.2.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

jest-environment-nightwatch

Nightwatch 2 environment for Jest. Nightwatch.js is an integrated test framework for performing automated end-to-end testing on web applications and websites, across all major browsers.

Build Status version Discord MIT License

npm install jest-environment-nightwatch

Usage:

Update your Jest configuration:

{
  testEnvironment: 'jest-environment-nightwatch',
  testEnvironmentOptions: {
    // Nightwatch related options
    headless: true,
    browserName: 'chrome',
    baseUrl: '',
    verbose: false,  
    output: true,
    env: null, 
    parallel: false,
    devtools: false,
    debug: false,
    autoStartSession: true,
    persistGlobals: true,
    configFile: './nightwatch.conf.js',
    globals: {}, 
    webdriver: {},
    timeout: null,
    enableGlobalApis: false,
    alwaysAsync: true,
    desiredCapabilities: {},
    async setup(browser) {},
    async teardown(browser) {},
  }
}

Nightwatch options

NameTypeDescriptionDefault
headlessBooleanRun Nightwatch in headless mode (available in Firefox, Chrome, Edge)true
browserNameStringBrowser name to use; available options are: chrome, firefox, edge, safarinone
baseUrlStringThe base url to use for the when using .navigateTo() with relative urls. When doing component testing it needs to be set to the url running the Vite dev server.http://localhost:3000
verboseBooleanEnable complete Nightwatch http logs.false
outputBooleanShow Nightwatch output.true
envStringNightwatch test environment to use, from nightwatch.conf.js. Learn more about test environments in the Nightwatch docs.none
parallelBooleanSet this to true when running tests in parallelfalse
devtoolsBooleanChrome only: automatically open the chrome devtoolsfalse
debugBooleanComponent testing only: pause the test execution after rendering the componentfalse
autoStartSessionBooleanStart the Nightwatch session automatically. If this is disabled, you'll need to call jestNightwatch.launchBrowser() in your tests.true
persistGlobalsBooleanPersist the same globals object between runs or have a (deep) copy of it per each test. Learn more about test globals in the Nightwatch docs.true
configFileStringThe Nightwatch config file to use. A config file will be auto-generated by default, but this allows you to change that. Learn more about the Nightwatch config in the Nightwatch docs../nightwatch.conf.js
globalsObjectA list of globals to be used in Nightwatch. Globals are available on browser.globals. Learn more about the Nightwatch test globals in the Nightwatch docs.none
webdriverObjectA list of Webdriver related settings to configure the Nightwatch Webdriver service. Learn more about the Nightwatch webdriver settings in the Nightwatch docs.none
timeoutNumberSet the global timeout for assertion retries before an assertion fails.5000
enableGlobalApisBooleanThe Nightwatch global APIs (element(), expect()) are disable by default.false
desiredCapabilitiesObjectDefine custom Selenium capabilities for the current session. Learn more about the specific browser driver that it is being used on the Nightwatch docs.none
setup()FunctionAdditional setup hook to be executed after Nightwatch has been started.none
teardown()FunctionAdditional teardown hook to be executed with the Nightwatch api object.none

API

global.browser

The Nightwatch browser API object. Unavailable when autoStartSession is off.

global.jestNightwatch

The Jest environment used the Nightwatch programmatic API to create the Nightwatch instance and export the browser API.

Available properties/methods:

  • .element(<locator>) - use the Nightwatch .element() API to locate elements in the page;
  • .updateCapabilities({ capabilities }) - used when autoStartSession is off in order to update the capabilities at run-time;
  • .launchBrowser() - used when autoStartSession is off in order to start the session and open the browser;
  • .settings - the Nightwatch settings object;
  • .nightwatch_client - the Nightwatch (internal) instance.

License

MIT

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago