Run seeded tests for all locales
Clear and concise description of the problem
Currently the seeded tests only run for the en locale.
Suggested solution
Run the seeded tests for all locales.
Pro:
- Generate visible examples for all locales
Con:
- Might cause a review overload due to the amount of generated test snapshots
Alternative
Do nothing extra
Additional context
The discussion originally came up in https://github.com/faker-js/faker/pull/1735#discussion_r1071751912
For now, I'm kind of against adding this as this reduces the probability that someone actually reviews the test snapshots.
Team decision
We will change the seeded tests to run all tests for all faker instances and verify, but only the main faker instance will write test snapshots. This will render the all_functional.spec.ts obsolete.
Is this required for v8? I could be implemented in v8-x as well, no?
I think its just nice to have.
Hi, I would like to work on this. I checked the current next branch: seededTests still exercises only the passed Faker instance, while test/all-functional.spec.ts covers the locale instances separately.
My plan is to have each generated seeded case exercise every non-base entry in allFakers, keep snapshots only for the passed Faker instance so the snapshot set does not balloon, and remove all-functional.spec.ts once the coverage is equivalent. Is that still the direction you want?
I ran a local spike against the current suite. Applying every parameterized seeded case to every locale creates false failures for valid locale differences, for example four-character word filters in zh_CN and abbreviated date forms where a locale does not define abbreviations.
A narrower replacement is green locally: run every no-argument seeded case against all non-base Faker instances, keep snapshots on the passed instance, and retain the existing location/person non-applicable combinations as typed exceptions. Parameterized cases stay on the snapshot instance. This preserves the meaningful coverage from all-functional.spec.ts while allowing that 37k-test file to be removed.
Does that scope match what you want today?
This preserves the meaningful coverage from all-functional.spec.ts while allowing that 37k-test file to be removed.
How many tests get added by the replacement? How much more time does it take vs how much time did the old take?
keep snapshots only for the passed Faker instance so the snapshot set does not balloon
I don't understand this text. Do you create snapshots for the new faker instances or not?
Is that still the direction you want?
Generally yes. We want to have a seeded test for each locale. Though now, might not be the ideal time to actually start the implementation. (We plan to wrap up v10 soon and start with v11, and that will contain some internally breaking/potentially conflicting changes) However, if you are still interested it might be worthwhile to discuss implementation plans before actually proceeding with the implementation. Do you have a structure in mind?
Also it might be worth checking for extremes. aka randomizer = () => 0 and () => 1*.
Thanks for the questions, and sorry for the slow reply. I went back to the original spike to make the scope and comparison precise.
By keeping snapshots on the passed instance, I meant no new locale snapshots: existing parameterized cases keep their snapshots; other locales get deterministic checks with seeds 42, 1337 and 1211. Both revisions matched the same 2,082 snapshots, with none added or updated.
I compared the original baseline e59f4995 with the local spike f1620add, running the same 27 seeded-module specs and including all-functional.spec.ts only on the baseline:
| Baseline | Spike | |
|---|---|---|
| Passed tests | 47,606 | 11,223 |
| Skipped / todo | 2 / 5 | 0 / 5 |
| Wall time | 80.5 s | 77.9 s |
Both runs passed. The spike removes 37,117 functional-suite test cases and adds 732 tests that each loop over the non-base locales. That is 36,385 fewer separately registered cases; the locale checks are inside the new tests. This was one sequential comparison on an ARM64 Android device using Linux Node 22.23.2, Vitest 4.1.9, two thread workers, and sequence seed 1749. Build and typechecking are excluded. The wall times are roughly similar; this is an indicative measurement of the original experiment, not a benchmark of current next.
The structure is one extra default-argument test per method and seed in TestGenerator, checking both the direct call and helpers.fake() template resolution. Parameterized cases stay on their original instance because their assumptions can be locale-specific. Known unavailable combinations have explicit expected failures rather than silent skips.
For the extreme randomizers, I would use separate bounded cases with method-specific assertions: zero can be a valid result, so the generic truthiness checks would be unsuitable. The upper endpoint should stay below 1 to match Randomizer.next()'s contract. Those cases are not implemented or included in the measurements above.
Current next at cc7ef649 still has the separate functional suite, and the module restructuring you mentioned is underway. Before porting the spike or opening a PR, does this default-argument coverage with no additional snapshots match the v11 direction, or do you want per-locale snapshot coverage instead?