mirror of
https://github.com/appium/appium.git
synced 2026-02-22 19:29:49 -06:00
This PR makes `chai` and `should()` _globals_ when using Mocha: - `chai` is configured with `chai-as-promised` - A `.mocharc.js` requires `./test/setup.js` _from the monorepo root_. - Updated the ESLint config to recognize the globals. - Updated Wallaby config All instances of `import chai...` and the like have been removed from all test files.
25 lines
954 B
JavaScript
25 lines
954 B
JavaScript
'use strict';
|
|
/**
|
|
* Mocha will load this file to configure the environment to use Chai as the
|
|
* assertion library. Since Chai is a singleton, we can run into problems when
|
|
* running files individually, if we have not carefully configured Chai in every
|
|
* single test file. This file means less boilerplate and less random test
|
|
* failures when running single test files.
|
|
*
|
|
* For simplicity, this file is _not_ transpiled. If it were, Mocha would need
|
|
* to load different versions of this file depending on the test context (are we
|
|
* running tests against the distfiles, or the source files?).
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
const chai = require('chai');
|
|
const chaiAsPromised = require('chai-as-promised');
|
|
|
|
// The `chai` global is set if a test needs something special.
|
|
// Most tests won't need this.
|
|
global.chai = chai.use(chaiAsPromised);
|
|
|
|
// `should()` is only necessary when working with some `null` or `undefined` values.
|
|
global.should = chai.should();
|