GithubHelp home page GithubHelp logo

travi / any Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 3.0 8.81 MB

random data generator for when test data is insignificant

Home Page: https://travi.github.io/any

License: MIT License

JavaScript 87.99% Shell 0.76% TypeScript 11.26%

any's Introduction

Random data generator

Node CI Workflow Status Codecov SLSA Level 2

Random data generator for when test data is insignificant. Tailoring data too closely for the domain can end up being confusing in tests because it distracts from the behavior that is actually important in the test. This is why I prefer to make it very clear when test data is insignificant by using a data generator. This library captures most of the patterns I use frequently.

Based on Chance.js

To save myself from needing to maintain the actual data generators, this library leverages Chance.js for generating the data. So why not just use Chance.js directly?

  • I find it annoying that an instance of Chance has to be created. Rather than initialize an instance in every module, I wrap a single instance for reuse throughout the tests.
  • I can set my default options to align with my typical conventions rather than having to repeatedly configure Chance.js's very flexible API
  • Lots of my tests need objects to be generated, but the structure of those objects typically does not matter. Chance.js does not have a simple-object generator, so I've included that on my own.
  • Many of my tests need lists generated. Like objects, Chance.js does not generate lists, so I've included this on my own.

Usage

npm node license monthly downloads Try @travi/any on RunKit

Install

$ npm install @travi/any --save-dev

Documentation

Contributing

PRs Welcome Conventional Commits Commitizen friendly Renovate semantic-release: angular

Dependencies

$ nvm install
$ npm install

Verification

$ npm test

Typescript Types

When making changes to the API, these changes must be reflected in the types file (index.d.ts). This library uses tsd to test the types. These tests can be found at index.d-test.ts. As you make changes to the API, first update index.d-test.ts with the expected results, then update index.d.ts with the appropriate types to satisfy the tests.

any's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jcjones1515 avatar justinwaite avatar renovate-bot avatar renovate[bot] avatar travi avatar travi-bot avatar trevtrich avatar ztoben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

any's Issues

documentation

at a minimum:

  • simpleObject
  • objectWithKeys
  • fromList
  • listOf

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

provide a way to seed the generator to enable reproducible runs

the randomness makes it really hard to track down an issue when it is not predictable when it will happen

  • somehow print the seed in the test output (at least in a failure case)
  • allow the ability to pass the seed to the generator so that the situation can be reproduced without waiting for it to randomly happen again
  • lint rule to prevent committing a generator with a hardcoded seed

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

add a fromList capability

for example:

any.fromList(['option 1', 'option 2', 'option 3'])

should return a randomly chosen value from the provided list

this should also work with any.listOf, but this should already work if provided as:

any.ListOf(() => any.fromList(['option 1', 'option 2', 'option 3']))

add a objectWithKeys capability

i have a use case where i have built out a fairly sizable object with the same random data generator for the values of each key. would be nice to be able to use this library to remove some of the duplication.

{
   foo: any.word(),
   bar: any.word(),
   baz: any.word()
   ...
}

to

any.objectWithKeys(['foo', 'bar', 'baz'], {factory: any.word});

indexed/keyed list generator

basically, objectWithKeys, but with the keys being provided from a key property from the value object (default to id).

  • should take an option to index/key by another property
  • factory should default to simpleObject, but with the defined key property injected (id by default)
  • factory should take the key as the first argument, just like objectWithKeys

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Replaced the old Node.js version in your .nvmrc with the new one

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Only passing length to any.word breaks

Since we started defaulting to a given number of syllables, we aren't able to conform to the any spec that only allows one or the other. We should check if length is passed and if so, don't default to the # of syllables.

export a default

so that the methods could be accessed as any.<method> w/o needing to import * as any

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Base branch does not exist - skipping

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm formatio Unavailable
npm referee Unavailable
npm referee-sinon Unavailable

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): lock file maintenance (master)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/node-ci.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-node v4.0.3@1e60f620b9541d16bece96c5465dc8ee9832be0b
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-node v4.0.3@1e60f620b9541d16bece96c5465dc8ee9832be0b
  • codecov/codecov-action v4.5.0@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
  • form8ion/.github master
.github/workflows/release.yml
  • form8ion/.github master
npm
package.json
  • @types/chance ^1.1.6
  • chance ^1.1.11
  • debug ^4.3.5
  • lodash ^4.17.21
  • mersenne-twister ^1.1.0
  • @babel/plugin-transform-exponentiation-operator 7.24.7
  • @babel/register 7.24.6
  • @rollup/plugin-babel 6.0.4
  • @travi/babel-preset 3.0.130
  • @travi/eslint-config 5.0.8
  • @travi/eslint-config-mocha 1.0.25
  • c8 10.1.2
  • chai 4.5.0
  • commitlint-config-travi 1.4.50
  • coveralls 3.1.1
  • cross-env 7.0.3
  • cz-conventional-changelog 3.3.0
  • formatio 1.2.0
  • globstar 1.0.0
  • husky 9.1.4
  • ls-engines 0.9.3
  • mocha 10.7.3
  • npm-run-all2 6.2.2
  • proxyquire 2.1.3
  • publint 0.2.10
  • referee 1.2.0
  • referee-sinon 1.0.3
  • remark-cli 12.0.1
  • remark-preset-lint-travi 6.0.5
  • remark-toc 9.0.0
  • rimraf 6.0.1
  • rollup 4.20.0
  • rollup-plugin-auto-external 2.0.0
  • sinon 18.0.0
  • tsd 0.31.1
  • node ^18.17 || >=20.6.1
nvm
.nvmrc
  • node 20

  • Check this box to trigger a request for Renovate to run again on this repository

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Support for < 0 for any.integer

It would be good to be able to do something like: any.integer({min:-25, max: 25}). It looks like the usage under the hood here is chance.natural, which (natural numbers) do not include negatives. With this api being integer, support for all integer values would be good.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.