orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
Orval generates mock string values as faker.word.sample() in msw responses. This method does not guarantee uniqueness. Also because orval uses the default length of the word faker often generates string of only 2 chars which increases the likelihood of duplicates.
I don't expect 100% unique values, but with some small modifications the mocks could become much more useful. Consider setting a larger default length of the strings you generate or even using a different Faker method like simpleFaker.string.uuid()
Any logs, error output, etc?
× SiteMaterialDetails > renders site material details 1070ms
→ Found multiple elements with the text: so
…
Any other comments?
Being able to set msw/faker settings in orval.config.js would be a fantastic quality of life improvement.
What versions are you using?
Please execute npx envinfo --system --npmPackages orval,zod,axios,msw,swr,@tanstack/react-query,@tanstack/vue-query,react,vue and paste the results here.
What are the steps to reproduce this issue?
Generated mocks return duplicate strings (and other values) which make it hard to write reliable tests.
What happens?
Our test suite is flaky because mocked data is often duplicated.
We follow Testing library's guiding principles and query priorities so we often query by role name/text. https://testing-library.com/docs/guiding-principles https://testing-library.com/docs/queries/about/#priority
Orval generates mock string values as
faker.word.sample()
in msw responses. This method does not guarantee uniqueness. Also because orval uses the default length of the word faker often generates string of only 2 chars which increases the likelihood of duplicates.https://github.com/orval-labs/orval/blob/master/packages/mock/src/faker/getters/scalar.ts#L253C20-L253C39
What were you expecting to happen?
I don't expect 100% unique values, but with some small modifications the mocks could become much more useful. Consider setting a larger default length of the strings you generate or even using a different Faker method like
simpleFaker.string.uuid()
Any logs, error output, etc?
…
Any other comments?
Being able to set msw/faker settings in orval.config.js would be a fantastic quality of life improvement.
What versions are you using?
Please execute
npx envinfo --system --npmPackages orval,zod,axios,msw,swr,@tanstack/react-query,@tanstack/vue-query,react,vue
and paste the results here.