-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new type of testing including a new test suite that's aimed solely at preventing the introduction of breaking changes. To this end the suite runs both the current version of the library and the latest released version and compares their behaviour.
- Loading branch information
1 parent
8f22e3e
commit b7763e0
Showing
7 changed files
with
190 additions
and
3 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,8 @@ | ||
{ | ||
"all": true, | ||
"include": ["src/", "index.js"], | ||
"exclude": [], | ||
"check-coverage": false, | ||
"reports-dir": "_reports/coverage/breakage", | ||
"reporter": ["lcov", "text"] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -79,6 +79,7 @@ | |
"prettier": "3.0.3", | ||
"publint": "0.2.3", | ||
"rollup": "4.0.2", | ||
"shescape-previous": "npm:[email protected]", | ||
"sinon": "16.1.0" | ||
}, | ||
"scripts": { | ||
|
@@ -98,7 +99,8 @@ | |
"audit:runtime": "better-npm-audit audit --production", | ||
"benchmark": "node bench/bench.js", | ||
"clean": "node script/clean.js", | ||
"coverage": "npm run coverage:unit && npm run coverage:integration && npm run coverage:e2e && npm run coverage:compat", | ||
"coverage": "npm run coverage:unit && npm run coverage:integration && npm run coverage:e2e && npm run coverage:compat && npm run coverage:breakage", | ||
"coverage:breakage": "c8 --config .c8/breakage.json npm run test:breakage", | ||
"coverage:compat": "c8 --config .c8/compat.json npm run test:compat", | ||
"coverage:e2e": "node script/run-platform-coverage.js e2e", | ||
"coverage:e2e:unix": "c8 --config .c8/e2e-unix.json npm run test:e2e", | ||
|
@@ -121,7 +123,8 @@ | |
"mutation": "npm run mutation:unit && npm run mutation:integration", | ||
"mutation:integration": "stryker run stryker.integration.config.js", | ||
"mutation:unit": "stryker run stryker.unit.config.js", | ||
"test": "npm run test:unit && npm run test:integration && npm run test:e2e && npm run test:compat", | ||
"test": "npm run test:unit && npm run test:integration && npm run test:e2e && npm run test:compat && npm run test:breakage", | ||
"test:breakage": "ava test/breakage/**/*.test.js", | ||
"test:compat": "ava test/compat/**/*.test.js", | ||
"test:compat-all": "nve 14.18.0,16.13.0,18.0.0,19.0.0,20.0.0 npm run test:compat --ignore-scripts", | ||
"test:e2e": "ava test/e2e/**/*.test.js --timeout 1m", | ||
|
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,8 @@ | ||
/** | ||
* @overview Provides testing utilities. | ||
* @license MIT | ||
*/ | ||
|
||
import * as arbitrary from "../_arbitraries.js"; | ||
|
||
export { arbitrary }; |
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,122 @@ | ||
/** | ||
* @overview Contains breakage tests for the `Shescape` class. | ||
* @license MIT | ||
*/ | ||
|
||
import { testProp } from "@fast-check/ava"; | ||
import * as fc from "fast-check"; | ||
|
||
import { arbitrary } from "./_.js"; | ||
|
||
import { Shescape } from "shescape"; | ||
import { Shescape as Previouscape } from "shescape-previous"; | ||
|
||
testProp( | ||
"Shescape#escape", | ||
[arbitrary.shescapeOptions(), fc.anything()], | ||
(t, options, arg) => { | ||
let result, previousResult, errored, previousErrored; | ||
let shescape, previouscape; | ||
|
||
try { | ||
shescape = new Shescape(options); | ||
result = shescape.escape(arg); | ||
} catch (_) { | ||
errored = true; | ||
} | ||
|
||
try { | ||
previouscape = new Previouscape(options); | ||
previousResult = previouscape.escape(arg); | ||
} catch (_) { | ||
previousErrored = true; | ||
} | ||
|
||
t.is(errored, previousErrored); | ||
t.is(typeof result, typeof previousResult); | ||
}, | ||
); | ||
|
||
testProp( | ||
"Shescape#escapeAll", | ||
[ | ||
arbitrary.shescapeOptions(), | ||
fc.oneof(fc.anything(), fc.array(fc.anything())), | ||
], | ||
(t, options, args) => { | ||
let result, previousResult, errored, previousErrored; | ||
let shescape, previouscape; | ||
|
||
try { | ||
shescape = new Shescape(options); | ||
result = shescape.escapeAll(args); | ||
} catch (_) { | ||
errored = true; | ||
} | ||
|
||
try { | ||
previouscape = new Previouscape(options); | ||
previousResult = previouscape.escapeAll(args); | ||
} catch (_) { | ||
previousErrored = true; | ||
} | ||
|
||
t.is(errored, previousErrored); | ||
t.is(typeof result, typeof previousResult); | ||
}, | ||
); | ||
|
||
testProp( | ||
"Shescape#quote", | ||
[arbitrary.shescapeOptions(), fc.anything()], | ||
(t, options, arg) => { | ||
let result, previousResult, errored, previousErrored; | ||
let shescape, previouscape; | ||
|
||
try { | ||
shescape = new Shescape(options); | ||
result = shescape.quote(arg); | ||
} catch (_) { | ||
errored = true; | ||
} | ||
|
||
try { | ||
previouscape = new Previouscape(options); | ||
previousResult = previouscape.quote(arg); | ||
} catch (_) { | ||
previousErrored = true; | ||
} | ||
|
||
t.is(errored, previousErrored); | ||
t.is(typeof result, typeof previousResult); | ||
}, | ||
); | ||
|
||
testProp( | ||
"Shescape#quoteAll", | ||
[ | ||
arbitrary.shescapeOptions(), | ||
fc.oneof(fc.anything(), fc.array(fc.anything())), | ||
], | ||
(t, options, args) => { | ||
let result, previousResult, errored, previousErrored; | ||
let shescape, previouscape; | ||
|
||
try { | ||
shescape = new Shescape(options); | ||
result = shescape.quoteAll(args); | ||
} catch (_) { | ||
errored = true; | ||
} | ||
|
||
try { | ||
previouscape = new Previouscape(options); | ||
previousResult = previouscape.quoteAll(args); | ||
} catch (_) { | ||
previousErrored = true; | ||
} | ||
|
||
t.is(errored, previousErrored); | ||
t.is(typeof result, typeof previousResult); | ||
}, | ||
); |