async-test-util
Advanced tools
Comparing version 1.6.3 to 1.7.0
@@ -5,3 +5,2 @@ const configuration = { | ||
'mocha', | ||
'browserify', | ||
'detectBrowsers' | ||
@@ -24,3 +23,3 @@ ], | ||
postDetection: function(availableBrowser) { | ||
// return ['Firefox']; // comment in to test specific browser | ||
return ['Chrome']; // comment in to test specific browser | ||
const browsers = availableBrowser | ||
@@ -39,3 +38,3 @@ .filter(b => !['PhantomJS', 'FirefoxAurora', 'FirefoxNightly'].includes(b)) | ||
'karma-mocha', | ||
'karma-browserify', | ||
'karma-webpack', | ||
'karma-chrome-launcher', | ||
@@ -52,3 +51,3 @@ 'karma-edge-launcher', | ||
preprocessors: { | ||
'../test/*.test.js': ['browserify'] | ||
'../test/*.test.js': ['webpack'] | ||
}, | ||
@@ -62,2 +61,5 @@ | ||
}, | ||
webpack: { | ||
mode: 'development' | ||
}, | ||
browsers: ['Chrome_travis_ci'], | ||
@@ -64,0 +66,0 @@ browserDisconnectTimeout: 12000, |
@@ -11,2 +11,3 @@ import assertThrows from './assert-throws'; | ||
import randomNumber from './random-number'; | ||
import randomBoolean from './random-boolean'; | ||
import resolveValues from './resolve-values'; | ||
@@ -28,2 +29,3 @@ import performanceNow from './performance-now'; | ||
randomNumber: randomNumber, | ||
randomBoolean: randomBoolean, | ||
resolveValues: resolveValues, | ||
@@ -36,2 +38,2 @@ performanceNow: performanceNow, | ||
export { assertThrows, clone, deepEqual, waitResolveable, waitUntil, wait, waitForever, runForever, randomString, randomNumber, resolveValues, performanceNow, isPromise, promisify }; | ||
export { assertThrows, clone, deepEqual, waitResolveable, waitUntil, wait, waitForever, runForever, randomString, randomNumber, randomBoolean, resolveValues, performanceNow, isPromise, promisify }; |
@@ -0,13 +1,14 @@ | ||
import isNode from 'is-node'; | ||
import NodeOnly from './require-on-node-only'; | ||
/** | ||
* same as perfommance.now() | ||
* same as performance.now() | ||
* but works in browsers and nodeJs | ||
* @link https://developer.mozilla.org/de/docs/Web/API/Performance/now | ||
*/ | ||
import isNode from 'is-node'; | ||
export default function performanceNow() { | ||
var perf = void 0; | ||
if (isNode) { | ||
var _require = require('perf_hooks'), | ||
performance = _require.performance; | ||
var performance = NodeOnly.perfHooks.performance; | ||
@@ -14,0 +15,0 @@ perf = performance; |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.promisify = exports.isPromise = exports.performanceNow = exports.resolveValues = exports.randomNumber = exports.randomString = exports.runForever = exports.waitForever = exports.wait = exports.waitUntil = exports.waitResolveable = exports.deepEqual = exports.clone = exports.assertThrows = undefined; | ||
exports.promisify = exports.isPromise = exports.performanceNow = exports.resolveValues = exports.randomBoolean = exports.randomNumber = exports.randomString = exports.runForever = exports.waitForever = exports.wait = exports.waitUntil = exports.waitResolveable = exports.deepEqual = exports.clone = exports.assertThrows = undefined; | ||
@@ -49,2 +49,6 @@ var _assertThrows = require('./assert-throws'); | ||
var _randomBoolean = require('./random-boolean'); | ||
var _randomBoolean2 = _interopRequireDefault(_randomBoolean); | ||
var _resolveValues = require('./resolve-values'); | ||
@@ -79,2 +83,3 @@ | ||
randomNumber: _randomNumber2['default'], | ||
randomBoolean: _randomBoolean2['default'], | ||
resolveValues: _resolveValues2['default'], | ||
@@ -96,2 +101,3 @@ performanceNow: _performanceNow2['default'], | ||
exports.randomNumber = _randomNumber2['default']; | ||
exports.randomBoolean = _randomBoolean2['default']; | ||
exports.resolveValues = _resolveValues2['default']; | ||
@@ -98,0 +104,0 @@ exports.performanceNow = _performanceNow2['default']; |
@@ -12,9 +12,17 @@ 'use strict'; | ||
var _requireOnNodeOnly = require('./require-on-node-only'); | ||
var _requireOnNodeOnly2 = _interopRequireDefault(_requireOnNodeOnly); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
/** | ||
* same as performance.now() | ||
* but works in browsers and nodeJs | ||
* @link https://developer.mozilla.org/de/docs/Web/API/Performance/now | ||
*/ | ||
function performanceNow() { | ||
var perf = void 0; | ||
if (_isNode2['default']) { | ||
var _require = require('perf_hooks'), | ||
performance = _require.performance; | ||
var performance = _requireOnNodeOnly2['default'].perfHooks.performance; | ||
@@ -25,5 +33,2 @@ perf = performance; | ||
return perf.now(); | ||
} /** | ||
* same as perfommance.now() | ||
* but works in browsers and nodeJs | ||
*/ | ||
} |
{ | ||
"name": "async-test-util", | ||
"version": "1.6.3", | ||
"version": "1.7.0", | ||
"description": "Util-functions that are be useful in async tests", | ||
"keywords": [ | ||
"async", | ||
"test", | ||
"mocha", | ||
"karma", | ||
"util", | ||
"wait", | ||
"wait-until", | ||
"assert", | ||
"is-promise", | ||
"random" | ||
], | ||
"main": "./dist/lib/index.js", | ||
@@ -33,4 +45,4 @@ "jsnext:main": "./dist/es/index.js", | ||
"babel-core": "6.26.3", | ||
"babel-eslint": "8.2.3", | ||
"babel-loader": "8.0.4", | ||
"babel-eslint": "10.0.1", | ||
"babel-loader": "8.0.5", | ||
"babel-plugin-transform-async-to-generator": "6.24.1", | ||
@@ -52,8 +64,6 @@ "babel-plugin-transform-class-properties": "6.24.1", | ||
"babel-preset-latest": "6.24.1", | ||
"browserify": "16.2.3", | ||
"cross-env": "5.2.0", | ||
"eslint": "4.19.1", | ||
"karma": "3.1.1", | ||
"karma-babel-preprocessor": "7.0.0", | ||
"karma-browserify": "5.3.0", | ||
"eslint": "5.14.1", | ||
"karma": "4.0.0", | ||
"karma-babel-preprocessor": "8.0.0", | ||
"karma-chrome-launcher": "2.2.0", | ||
@@ -68,5 +78,7 @@ "karma-coverage": "1.1.2", | ||
"karma-safari-launcher": "1.0.0", | ||
"karma-webpack": "3.0.5", | ||
"mocha": "5.2.0", | ||
"node": "11.2.0", | ||
"rimraf": "2.6.2" | ||
"node": "11.10.0", | ||
"rimraf": "2.6.3", | ||
"webpack": "4.29.5" | ||
}, | ||
@@ -79,3 +91,8 @@ "dependencies": { | ||
"is-node": "1.0.2" | ||
}, | ||
"browser": { | ||
"./src/require-on-node-only.js": false, | ||
"./dist/es/require-on-node-only.js": false, | ||
"./dist/lib/require-on-node-only.js": false | ||
} | ||
} |
@@ -169,3 +169,2 @@ # async-test-util | ||
```javascript | ||
// instead of this | ||
@@ -189,9 +188,8 @@ const database = await connectDatabase(); | ||
## isPromise() | ||
Returns true if the given value is a `Promise`; | ||
```javascript | ||
const is = AsyncTestUtil.isPromise(myAsyncFunction()); // true | ||
const is = AsyncTestUtil.isPromise('foobar'); // false | ||
``` | ||
@@ -203,4 +201,3 @@ | ||
``` javascript | ||
```javascript | ||
const ensurePromise = AsyncTestUtil.isPromise(maybeAsyncFunction()); | ||
@@ -210,3 +207,2 @@ | ||
ensurePromise.then(/* ... */) | ||
``` | ||
@@ -219,3 +215,2 @@ | ||
```javascript | ||
console.log(AsyncTestUtil.randomString()); | ||
@@ -239,3 +234,2 @@ // > 'rhfkx' | ||
```javascript | ||
console.log(AsyncTestUtil.randomNumber()); | ||
@@ -251,2 +245,11 @@ // > 56 | ||
## randomBoolean() | ||
Creates a random boolean. Returns `true` or `false`. | ||
```javascript | ||
console.log(AsyncTestUtil.randomBoolean()); | ||
// > true | ||
``` | ||
## clone() | ||
@@ -285,1 +288,14 @@ | ||
``` | ||
## performanceNow() | ||
Works equal to [performance.now](https://developer.mozilla.org/de/docs/Web/API/Performance/now) but works in browsers and nodeJs. | ||
```javascript | ||
it('should take less then 200 milliseconds', () => { | ||
const now = AsyncTestUtil.performanceNow(); // in milliseconds | ||
await doSomething(); | ||
const later = AsyncTestUtil.performanceNow(); // in milliseconds | ||
assert.ok((now + 50 * 1000 ) > later); | ||
}); | ||
``` |
@@ -127,2 +127,9 @@ /** | ||
/** | ||
* creates a random boolean | ||
* @return {boolean} | ||
*/ | ||
export const randomBoolean: randomBooleanType; | ||
type randomBooleanType = () => boolean; | ||
declare const _default: { | ||
@@ -138,2 +145,3 @@ assertThrows: assertThrowsType, | ||
randomNumber: randomNumberType, | ||
randomBoolean: randomBooleanType, | ||
resolveValues: resolveValuesType, | ||
@@ -140,0 +148,0 @@ waitResolveable: waitResolveableType, |
@@ -11,2 +11,3 @@ import assertThrows from './assert-throws'; | ||
import randomNumber from './random-number'; | ||
import randomBoolean from './random-boolean'; | ||
import resolveValues from './resolve-values'; | ||
@@ -28,2 +29,3 @@ import performanceNow from './performance-now'; | ||
randomNumber, | ||
randomBoolean, | ||
resolveValues, | ||
@@ -47,2 +49,3 @@ performanceNow, | ||
randomNumber, | ||
randomBoolean, | ||
resolveValues, | ||
@@ -49,0 +52,0 @@ performanceNow, |
@@ -0,9 +1,10 @@ | ||
import isNode from 'is-node'; | ||
import NodeOnly from './require-on-node-only'; | ||
/** | ||
* same as perfommance.now() | ||
* same as performance.now() | ||
* but works in browsers and nodeJs | ||
* @link https://developer.mozilla.org/de/docs/Web/API/Performance/now | ||
*/ | ||
import isNode from 'is-node'; | ||
export default function performanceNow() { | ||
@@ -14,3 +15,3 @@ let perf; | ||
performance | ||
} = require('perf_hooks'); | ||
} = NodeOnly.perfHooks; | ||
perf = performance; | ||
@@ -17,0 +18,0 @@ } else |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58365
56
1125
294