faker
faker copied to clipboard
feat: return randomly one of animals different types
A new feature for animal module, The function called ainmal.random() which select randomly of animal types then pick up randomly one of selected animal.
here's code ` faker.ainmal.random();
`
Please add some tests for the new method and run pnpm run preflight.
Please add some tests for the new method and run
pnpm run preflight.
i ran cmd you mentioned and add test functionality too.
See https://github.com/faker-js/faker/actions/runs/4263046776/jobs/7419510093
You can run pnpm run test to run the tests locally
You can see there are a couple of problems - your JSDoc needs to include @since - as this is a new method for 8.0.0 should have @since 8.0.0
Also the snapshot tests are out of date, you should be able to regenerate them by pressing "u" after pnpm run test completes, otherwise pnpm run preflight again should also do this.
See https://github.com/faker-js/faker/actions/runs/4263046776/jobs/7419510093
You can run
pnpm run testto run the tests locallyYou can see there are a couple of problems - your JSDoc needs to include
@since- as this is a new method for 8.0.0 should have@since 8.0.0Also the snapshot tests are out of date, you should be able to regenerate them by pressing "u" after pnpm run test completes, otherwise
pnpm run preflightagain should also do this.
when i run npm run test test/animal.spec.ts it oky but running this command npm run test i get error which so wired i was working on these two files src/modules/animal/index.ts, test/animal.spec.ts
Please paste the output if you get errors and we can help diagnose what the problem is.
Please paste the output if you get errors and we can help diagnose what the problem is.
node -v 16.18.1 Ubuntu 22.04.1 LTS
) first error
test/docs/versions.spec.ts (1 test | 1 failed) 14ms
❯ test/docs/versions.spec.ts > docs versions > oldVersions > should have a complete set of oldVersions
→ Cannot read properties of undefined (reading 'version')
) second error
test/faker.spec.ts (71 tests | 1 failed) 41ms
❯ test/faker.spec.ts > faker > should not log anything on startup
→ Cannot find module '/home/hope/githup/faker/dist/cjs/index.js'. Please verify that the package.json has a valid "main" entry
) thired error
❯ test/locale-imports.spec.ts (236 tests | 177 failed) 952ms
❯ test/locale-imports.spec.ts > locale imports > should be possible to directly require('@faker-js/faker/locale/af_ZA')
→ Cannot find module '../dist/cjs/locale/af_ZA'
Require stack:
then gose to error
at the end it must be conflict betwen my system node -v and repo node -v
I cannot diagnose the first error because you didn't sent the complete error message, usually it shows the failed line number as well. Like this:

(btw you can fix the failing tests by running pnpm run preflight or pnpm run test -u
For the second and third error, you have to run pnpm run preflight or pnpm run build once to fix them.
after upgrade node js to 18.14.2 and run this cmd pnpm run test -u now i got this error
test/docs/versions.spec.ts (1 test | 1 failed) 12ms ❯ test/docs/versions.spec.ts > docs versions > oldVersions > should have a complete set of oldVersions → Cannot read properties of undefined (reading 'version')
after upgrade node js to 18.14.2 and run this cmd pnpm run test -u now i got this error
test/docs/versions.spec.ts (1 test | 1 failed) 12ms ❯ test/docs/versions.spec.ts > docs versions > oldVersions > should have a complete set of oldVersions → Cannot read properties of undefined (reading 'version')
Please post the complete error.
after upgrade node js to 18.14.2 and run this cmd pnpm run test -u now i got this error test/docs/versions.spec.ts (1 test | 1 failed) 12ms ❯ test/docs/versions.spec.ts > docs versions > oldVersions > should have a complete set of oldVersions → Cannot read properties of undefined (reading 'version')
Please post the complete error.
this is a error
FAIL test/docs/versions.spec.ts > docs versions > oldVersions > should have a complete set of oldVersions
TypeError: Cannot read properties of undefined (reading 'version')
❯ test/docs/versions.spec.ts:23:66
`
21| semver.valid(version)
22| );
23| const latestMajorRelease = semver.major(releaseVersions[0].version);
| ^
24| for (let i = 0; i < releaseVersions.length; i++) {
25| const { version, link } = releaseVersions[i];
`
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed | 35 passed (36)
Tests 1 failed | 43752 passed | 1042 skipped | 25 todo (44820)
Start at 20:38:50
Duration 44.95s (transform 4.52s, setup 785ms, collect 155.86s, tests 44.76s)
ELIFECYCLE Command failed with exit code 1.
ERROR: "test:update-snapshots" exited with 1. ELIFECYCLE Command failed with exit code 1.
I will try to reproduce and fix the error locally.
I will try to reproduce and fix the error locally.
i dig in codes and find out the bug,
`
// version must be number x.y.z not string next or latest
// this line of code semver.valid() return null
// it should be like that semver.valid(semver.coerce('42.6.7.9.3-alpha'))
const releaseVersions = oldVersions.filter(({ version }) =>
semver.valid(version)
);
//this line code is not working because is empty array
const latestMajorRelease = semver.major(releaseVersions[0].version);
`
I think you are almost right. You only forked the next branch, but not the v8 or v7 branches. So it doesnt find them when you build the project locally. I have to think how I can adjust the test to ensure the test works as expected for us, but doesnt break other users builds.
Codecov Report
Merging #1871 (0f371d8) into next (25bd847) will increase coverage by
0.00%. The diff coverage is100.00%.
Additional details and impacted files
@@ Coverage Diff @@
## next #1871 +/- ##
=======================================
Coverage 99.62% 99.63%
=======================================
Files 2355 2355
Lines 236403 236494 +91
Branches 1153 1158 +5
=======================================
+ Hits 235527 235623 +96
+ Misses 854 849 -5
Partials 22 22
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/modules/animal/index.ts | 100.00% <100.00%> (ø) |
|
| src/modules/git/index.ts | 100.00% <0.00%> (ø) |
|
| src/modules/image/index.ts | 100.00% <0.00%> (ø) |
|
| src/modules/company/index.ts | 100.00% <0.00%> (ø) |
|
| src/modules/image/providers/unsplash.ts | 100.00% <0.00%> (ø) |
|
| src/modules/image/providers/placeholder.ts | 100.00% <0.00%> (ø) |
|
| src/modules/image/providers/lorempicsum.ts | 91.71% <0.00%> (+0.05%) |
:arrow_up: |
| src/modules/location/index.ts | 98.92% <0.00%> (+0.21%) |
:arrow_up: |
| src/modules/internet/user-agent.ts | 90.23% <0.00%> (+0.88%) |
:arrow_up: |
On hold until user interest has been confirmed. Please upvote the related issue #1618 if you want this to be pushed.
Superseded by #2786