Behavior-critical Masker test cases shared across language ports. Both packages/js and packages/php load these and assert their local Masker reproduces the expected output. Adding a fixture exercises every port automatically.
Each fixture file is a JSON array of cases:
[
{
"name": "human-readable description",
"input": "You have 5 apples",
"config": {
"ignoreWords": ["..."],
"allowedInlineTags": ["a", "b", ...]
},
"expected": {
"masked": "You have {{0}} apples",
"variables": [{ "value": "5", "type": "number" }],
"tagAttributes": { "a0": { "href": "/x" } },
"casePattern": "lower",
"leadingWhitespace": "",
"trailingWhitespace": ""
}
}
]config.ignoreWordsdefaults to[]config.allowedInlineTagsdefaults to["a", "b", "i", "u", "strong", "em", "span", "small", "mark", "del"]expected.tagAttributesdefaults to{}expected.casePatterndefaults to"lower"expected.leadingWhitespaceandexpected.trailingWhitespacedefault to""
Either a plain string or an object with metadata:
"Mary"
{ "word": "Mary", "meta": { "gender": "female" } }When metadata is present, the corresponding expected.variables[] entry should include a meta field.
masker/numbers.json— integers, decimals, negatives, percentagesmasker/dates.json— MM/DD/YYYY, YYYY-MM-DD, DD.MM.YYYYmasker/ignore-words.json— string entries, multi-word, longest-firstmasker/urls-emails.json— URLs and email addressesmasker/symbols.json— ©, ®, ™, currency, miscellaneousmasker/inline-tags.json— tag normalization, attribute extraction, nestingmasker/comments.json— HTML comments masked as variablesmasker/case-detection.json— upper/lower/mixed pattern detectionmasker/whitespace.json— leading/trailing whitespace handling
- Pick the right category file (or create a new one).
- Add a case with a descriptive
name. - Run the JS suite (
cd packages/js && npm run test) — the fixture-driven test will pick it up. - Run the PHP suite once that port exists. Failures here mean the ports diverge — fix in whichever port is wrong.