Files
appium/test/setup.js
Christopher Hiller ee00285b38 chore: global chai
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.
2021-08-13 10:40:52 -07:00

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();