diff --git a/package.json b/package.json index 0ce673c..c203fe8 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,6 @@ "author": "Jeff Dickey @jdxcode", "bugs": "https://github.com/jdxcode/fancy-mocha/issues", "dependencies": { - "chai": "^4.1.2", - "chai-as-promised": "^7.1.1", "lodash": "^4.17.4", "stdout-stderr": "^0.1.4" }, @@ -18,6 +16,8 @@ "@types/lodash": "^4.14.93", "@types/mocha": "^2.2.46", "@types/node": "^9.3.0", + "chai": "^4.1.2", + "chai-as-promised": "^7.1.1", "eslint": "^4.16.0", "eslint-config-dxcli": "^1.1.4", "husky": "^0.14.3", diff --git a/src/chai.ts b/src/chai.ts index 66e2f21..db87e53 100644 --- a/src/chai.ts +++ b/src/chai.ts @@ -1,5 +1,15 @@ -import * as chai from 'chai' -import * as chaiAsPromised from 'chai-as-promised' -chai.use(chaiAsPromised) +// tslint:disable no-unused -export const {expect} = chai +const tryRequire = (module: string) => { + try { + return require(module) + } catch (_) { + } +} + +const chai: Chai.ChaiStatic = tryRequire('chai') + +const chaiAsPromised = tryRequire('chai-as-promised') +if (chai && chaiAsPromised) chai.use(chaiAsPromised) + +export const expect = chai && chai.expect