-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add node:test runner and unit tests for API exports
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {describe, it} from 'node:test'; | ||
import assert from 'assert'; | ||
import { | ||
onCLS, | ||
onFCP, | ||
onFID, | ||
onINP, | ||
onLCP, | ||
onTTFB, | ||
CLSThresholds, | ||
FCPThresholds, | ||
FIDThresholds, | ||
INPThresholds, | ||
LCPThresholds, | ||
TTFBThresholds, | ||
} from 'web-vitals'; | ||
|
||
describe('index', () => { | ||
it('exports Web Vitals metrics functions', () => { | ||
[onCLS, onFCP, onFID, onINP, onLCP, onTTFB].forEach((onFn) => | ||
assert(typeof onFn === 'function') | ||
); | ||
}); | ||
|
||
it('exports Web Vitals metric thresholds', () => { | ||
assert.deepEqual(CLSThresholds, [0.1, 0.25]); | ||
assert.deepEqual(FCPThresholds, [1800, 3000]); | ||
assert.deepEqual(FIDThresholds, [100, 300]); | ||
assert.deepEqual(INPThresholds, [200, 500]); | ||
assert.deepEqual(LCPThresholds, [2500, 4000]); | ||
assert.deepEqual(TTFBThresholds, [800, 1800]); | ||
}); | ||
}); |