now testing properly
This commit is contained in:
parent
c54644949e
commit
638c1a8c8c
@ -21,7 +21,7 @@ minimal and fast loading plugin for startup time measuring
|
|||||||
## Usage
|
## Usage
|
||||||
Use TypeScript for best in class instellisense.
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```typescript
|
```javascript
|
||||||
// Put the following at the start of your module
|
// Put the following at the start of your module
|
||||||
import * as early from "early";
|
import * as early from "early";
|
||||||
early.start("myModuleName");
|
early.start("myModuleName");
|
||||||
|
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
const beautycolor = require("beautycolor");
|
const beautycolor = require("beautycolor");
|
||||||
const smartq = require("smartq");
|
const smartq = require("smartq");
|
||||||
@ -22,8 +23,8 @@ exports.stop = () => {
|
|||||||
let endTime = Date.now();
|
let endTime = Date.now();
|
||||||
let earlyExecutionTime = (endTime - startTime);
|
let earlyExecutionTime = (endTime - startTime);
|
||||||
let earlyExecutionTimeString = (earlyExecutionTime / 1000).toString();
|
let earlyExecutionTimeString = (earlyExecutionTime / 1000).toString();
|
||||||
console.log(`... finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`);
|
console.log(`OK! -> finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`);
|
||||||
done.resolve(earlyExecutionTime);
|
done.resolve(earlyExecutionTime);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDJDQUEwQztBQUMxQyxpQ0FBZ0M7QUFFaEMsSUFBSSxN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RyxNQUFNLENBQUMsS0FBSyxFQUFVLENBQUE7SUFDakMsSUFBSSxPQUFPLEdBQUcsSUFBSSxDQUFDLEdBQUcsRUFBRSxDQUFBO0lBQ3hCLElBQUksa0JBQWtCLEdBQVcsQ0FBQyxPQUFPLEdBQUcsU0FBUyxDQUFDLENBQUE7SUFDdEQsSUFBSSx3QkFBd0IsR0FBVyxDQUFDLGtCQUFrQixHQUFHLElBQUksQ0FBQyxDQUFDLFFBQVEsRUFBRSxDQUFBO0lBQzdFLE9BQU8sQ0FBQyxHQUFHLENBQUMsa0NBQWtDLFdBQVcsQ0FBQyxhQUFhLENBQUMsd0JBQXdCLEVBQUUsTUFBTSxDQUFDLEVBQUUsQ0FBQyxDQUFBO0lBQzVHLElBQUksQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQTtJQUNoQyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQTtBQUNyQixDQUFDLENBQUEifQ==
|
@ -21,8 +21,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/early#readme",
|
"homepage": "https://gitlab.com/pushrocks/early#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^6.0.0",
|
"smartdelay": "^1.0.1",
|
||||||
"typings-test": "^1.0.3"
|
"tapbundle": "^1.0.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautycolor": "^1.0.7",
|
"beautycolor": "^1.0.7",
|
||||||
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
17
test/test.js
17
test/test.js
@ -1,17 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const early = require("../dist/index");
|
|
||||||
describe('early', function () {
|
|
||||||
it('.start()', function (done) {
|
|
||||||
this.timeout(10000);
|
|
||||||
early.start('early');
|
|
||||||
setTimeout(done, 5000);
|
|
||||||
});
|
|
||||||
it('.stop()', function (done) {
|
|
||||||
early.stop()
|
|
||||||
.then(() => {
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQix1Q0FBdUM7QUFFdkMsUUFBUSxDQUFDLE9BQU8sRUFBRTtJQUNoQixFQUFFLENBQUMsVUFBVSxFQUFFLFVBQVUsSUFBSTtRQUMzQixJQUFJLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxDQUFBO1FBQ25CLEtBQUssQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUE7UUFDcEIsVUFBVSxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQTtJQUN4QixDQUFDLENBQUMsQ0FBQTtJQUNGLEVBQUUsQ0FBQyxTQUFTLEVBQUUsVUFBVSxJQUFJO1FBQzFCLEtBQUssQ0FBQyxJQUFJLEVBQUU7YUFDVCxJQUFJLENBQUM7WUFDSixJQUFJLEVBQUUsQ0FBQTtRQUNSLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDLENBQUMsQ0FBQSJ9
|
|
21
test/test.ts
21
test/test.ts
@ -1,16 +1,11 @@
|
|||||||
import 'typings-test'
|
import { expect, tap } from 'tapbundle'
|
||||||
|
import * as smartdelay from 'smartdelay'
|
||||||
import early = require('../dist/index')
|
import early = require('../dist/index')
|
||||||
|
|
||||||
describe('early', function () {
|
tap.test('.start()', async () => {
|
||||||
it('.start()', function (done) {
|
early.start('early')
|
||||||
this.timeout(10000)
|
await smartdelay.delayFor(2000)
|
||||||
early.start('early')
|
|
||||||
setTimeout(done, 5000)
|
|
||||||
})
|
|
||||||
it('.stop()', function (done) {
|
|
||||||
early.stop()
|
|
||||||
.then(() => {
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
tap.test('.stop()', async () => {
|
||||||
|
await early.stop()
|
||||||
|
})
|
@ -25,7 +25,7 @@ export let stop = (): Promise<number> => {
|
|||||||
let endTime = Date.now()
|
let endTime = Date.now()
|
||||||
let earlyExecutionTime: number = (endTime - startTime)
|
let earlyExecutionTime: number = (endTime - startTime)
|
||||||
let earlyExecutionTimeString: string = (earlyExecutionTime / 1000).toString()
|
let earlyExecutionTimeString: string = (earlyExecutionTime / 1000).toString()
|
||||||
console.log(`... finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`)
|
console.log(`OK! -> finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`)
|
||||||
done.resolve(earlyExecutionTime)
|
done.resolve(earlyExecutionTime)
|
||||||
return done.promise
|
return done.promise
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user