MCPcopy
hub / github.com/thinkjs/thinkjs / _isRunInTest

Method _isRunInTest

lib/application.js:189–225  ·  view source on GitHub ↗

* check test env

()

Source from the content-addressed store, hash-verified

187 * check test env
188 */
189 _isRunInTest() {
190 const {
191 JEST_WORKER_ID,
192 NODE_ENV,
193 THINK_UNIT_TEST
194 } = process.env;
195
196 /**
197 * https://github.com/facebook/jest/pull/5860
198 * provide process.env.JEST_WORKER_ID="1" for cases when Jest * runs the tests on the main process.
199 */
200 const runInJest = JEST_WORKER_ID !== undefined;
201 /**
202 * https://github.com/avajs/ava/blob/master/docs/01-writing-tests.md
203 * AVA will set process.env.NODE_ENV to test, unless the
204 * NODE_ENV environment variable has been set.
205 */
206 const runInAva = NODE_ENV === 'test';
207
208 /**
209 * https://github.com/AndreasPizsa/detect-mocha/blob/master/index.js
210 */
211 const runInMocha = [
212 'afterEach',
213 'after',
214 'beforeEach',
215 'before',
216 'describe',
217 'it'
218 ].every(name => global[name] instanceof Function);
219
220 /**
221 * Other Test framework we can't detect should add environment * by user
222 */
223 const runInUserDefine = !!THINK_UNIT_TEST;
224 return runInJest || runInAva || runInMocha || runInUserDefine;
225 }
226 /**
227 * run
228 */

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected