Repository navigation
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #4220 +/- ##
==========================================
- Coverage 99.14% 99.09% -0.06%
==========================================
Files 1185 1188 +3
Lines 3978 3978
Branches 722 708 -14
==========================================
- Hits 3944 3942 -2
- Misses 29 31 +2
Partials 5 5
🚀 New features to boost your workflow:
|
Member
Author
|
Well, I would have expected more test errors... |
ST-DDT
marked this pull request as ready for review
October 28, 2026 23:10
ST-DDT
commented
Oct 28, 2026
ST-DDT
left a comment
Member
Author
There was a problem hiding this comment.
Ready for review - See PR description for review hints/guide
Member
Author
|
ToDo: Check test from #4225 it('should not reference src/faker.ts in its import graph', () => {
const project = getEmptyProject();
const entryFile = project.addSourceFileAtPath('src/simple-faker.ts');
const fakerFilePath = project
.addSourceFileAtPath('src/faker.ts')
.getFilePath();
function resolveModuleFile(
sourceFile: SourceFile,
moduleSpecifier: string
): SourceFile {
const base = resolve(sourceFile.getDirectoryPath(), moduleSpecifier);
const resolved =
project.addSourceFileAtPathIfExists(`${base}.ts`) ??
project.addSourceFileAtPathIfExists(`${base}/index.ts`);
if (resolved == null) {
throw new Error(
`Could not resolve '${moduleSpecifier}' from ${sourceFile.getFilePath()}`
);
}
return resolved;
}
const visited = new Map<string, string[]>([
[entryFile.getFilePath(), [entryFile.getFilePath()]],
]);
const queue: SourceFile[] = [entryFile];
let sourceFile: SourceFile | undefined;
while ((sourceFile = queue.shift()) != null) {
const chain = visited.get(sourceFile.getFilePath()) ?? [];
const declarations = [
...sourceFile.getImportDeclarations(),
...sourceFile.getExportDeclarations(),
].filter((declaration) => !declaration.isTypeOnly());
for (const declaration of declarations) {
const moduleSpecifier = declaration.getModuleSpecifierValue();
if (moduleSpecifier == null || !moduleSpecifier.startsWith('.')) {
continue;
}
const target = resolveModuleFile(sourceFile, moduleSpecifier);
const targetPath = target.getFilePath();
if (visited.has(targetPath)) {
continue;
}
const targetChain = [...chain, targetPath];
expect(
targetPath,
`Import chain: ${targetChain.join(' -> ')}`
).not.toBe(fakerFilePath);
visited.set(targetPath, targetChain);
queue.push(target);
}
}
expect(visited.size).toBeGreaterThan(1);
}); |
Member
Author
|
Suggestions applied - Ready for Review. |
ST-DDT
force-pushed
the
fix/SimpleFaker-loads-Faker
branch
from
November 2, 2026 21:38
ac100fc to
94266d2
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Description
Loading
SimpleFakeralso loadsFakerin a circular dependency.This is bad for tree-shaking, but also causes issues for tests that load only
simple-faker.tsdirectly, because it tries to loadFakerbeforeSimpleFakercompletes its initialization. The error does not occur when importing from the root, because then faker.ts gets loaded before simple-faker.ts due to alphabetical import ordering.https://github.com/faker-js/faker/actions/runs/40758552789/job/123067211980?pr=4219
Reproduction
pnpm run test run test/simple-faker.spec.tsError: SimpleFaker must not load src/faker.ts: src/simple-faker.ts:7:1 -> src/modules/location/module.ts:4:1 -> src/modules/location/city.ts:2:1 -> src/faker.tsSolution
SimpleModules into separate files to isolate the two initialization paths.Review-Hints
scripts/module-tree/generate-module-tree.tswith whitespace diff ignored