[
  {
    "path": ".babelrc",
    "content": "{\n    \"env\": {\n        \"test\": {\n            \"presets\": [\n                [\n                    \"@babel/preset-env\",\n                    {\n                        \"targets\": {\n                            \"node\": \"current\"\n                        }\n                    }\n                ]\n            ]\n        }\n    },\n    \"presets\": [\n        [\n            \"@babel/preset-env\",\n            {\n                \"useBuiltIns\": \"usage\",\n                \"shippedProposals\": true,\n                \"corejs\": 3,\n                \"targets\": {\n                    \"browsers\": [\"last 2 major versions\", \"not dead\", \"not IE 11\"]\n                }\n            }\n        ]\n    ]\n}\n"
  },
  {
    "path": ".eslintignore",
    "content": "node_modules\ndist\npackage-lock.json\n"
  },
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n    env: {\n        node: true,\n        browser: true,\n        es2020: true,\n    },\n    parser: 'babel-eslint',\n    parserOptions: {\n        ecmaVersion: 2020,\n        sourceType: 'module',\n    },\n    plugins: ['prettier', 'babel'],\n    extends: [\n        'eslint:recommended',\n        'prettier',\n        'plugin:prettier/recommended',\n        'plugin:import/errors',\n        'plugin:import/warnings',\n        'plugin:jest/recommended',\n        'plugin:jest/style',\n        'plugin:cypress/recommended',\n    ],\n    rules: {\n        'prettier/prettier': 'error',\n        'babel/no-unused-expressions': 'error',\n    },\n    overrides: [\n        {\n            files: ['cypress/integration/*.spec.js'],\n            rules: {\n                'jest/expect-expect': 'off',\n            },\n        },\n    ],\n};\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/bug_report.md",
    "content": "---\nname: '🐛 Bug Report'\nabout: Bugs, missing documentation, or unexpected behavior 🤔.\ntitle: 'Bug: '\n---\n\n<!--\n  Please provide a clear and concise description of what the bug is. Include\n  screenshots if needed. Please test using the latest version of the relevant\n  React packages to make sure your issue has not already been fixed.\n-->\n\n-   `gremlins.js` version:\n-   `node` version:\n-   `npm` (or `yarn`) version:\n-   browser version:\n\n## Steps To Reproduce\n\n1. 2.\n\n<!--\n  Your bug will get fixed much faster if we can run your code and it doesn't\n  have dependencies other than gremlins.js. Issues without reproduction steps or\n  code examples may be immediately closed as not actionable.\n-->\n\nLink to code example:\n\n<!--\n  Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a\n  repository on GitHub, or provide a minimal code example that reproduces the\n  problem. You may provide a screenshot of the application if you think it is\n  relevant to your bug report. Here are some tips for providing a minimal\n  example: https://stackoverflow.com/help/mcve.\n-->\n\n## The current behavior\n\n<!-- Please provide the full error message/screenshots/anything -->\n\n## The expected behavior\n\n### Suggested solution:\n\n<!--\nIt's ok if you don't have a suggested solution, but it really helps if you could\ndo a little digging to come up with some suggestion of how to improve things.\n-->\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/config.yml",
    "content": "blank_issues_enabled: false\ncontact_links:\n- name: 📝 Code of Conduct\n  url: https://github.com/marmelab/gremlins.js/blob/master/CODE_OF_CONDUCT.md\n  about: ❤ Be nice to other members of the community. ☮ Behave.\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/feature_request.md",
    "content": "---\nname: 💡 Feature Request\nabout: I have a suggestion (and might want to implement myself 🙂)!\n---\n\n<!--\n\nVote on feature requests by adding a 👍. This helps maintainers prioritize what\nto work on.\n\n* Please fill out this template with all the relevant information so we can\n  understand what's going on and fix the issue. We appreciate bugs filed and PRs\n  submitted!\n\n* Please make sure that you are familiar with and follow the Code of Conduct for\n  this project (found in the CODE_OF_CONDUCT.md file).\n\n-->\n\n### Describe the feature you'd like:\n\n<!--\nA clear and concise description of what you want to happen. Add any considered\ndrawbacks.\n-->\n\n### Suggested implementation:\n\n<!-- Helpful but optional 😀 -->\n\n### Describe alternatives you've considered:\n\n<!--\nA clear and concise description of any alternative solutions or features you've\nconsidered.\n-->\n\n### Teachability, Documentation, Adoption, Migration Strategy:\n\n<!--\nIf you can, explain how users will be able to use this and possibly write out a\nversion of the docs.\n-->\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE/question.md",
    "content": "---\nname: ❓ Question\nabout: Ask a question not related to implementation here\nlabel: question\n---\n\n🚨 The issue tracker is not for implementation questions 🚨\n"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "👉 Please follow one of these issue templates:\n\n-   https://github.com/marmelab/gremlins.js/issues/new/choose\n\nNote: to keep the backlog clean and actionable, issues may be immediately closed if they do not follow one of the above issue templates.\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "<!--\nThanks for your interest in the project. Bugs filed and PRs submitted are appreciated!\n\nPlease make sure that you are familiar with and follow the Code of Conduct for\nthis project (found in the CODE_OF_CONDUCT.md file).\n\nAlso, please make sure you're familiar with and follow the instructions in the\ncontributing guidelines (found in the CONTRIBUTING.md file).\n\nPlease fill out the information below to expedite the review and (hopefully)\nmerge of your pull request!\n-->\n\n<!-- What changes are being made? (What feature/bug is being fixed here?) -->\n\n**What**:\n\n<!-- Why are these changes necessary? -->\n\n**Why**:\n\n<!-- How were these changes implemented? -->\n\n**How**:\n\n<!-- Have you done all of these things?  -->\n\n**Checklist**:\n\n-   [ ] Documentation added to the README.md file\n-   [ ] Tests\n-   [ ] Typescript definitions updated\n-   [ ] RFR, Ready for review label\n\n<!-- feel free to add additional comments -->\n"
  },
  {
    "path": ".gitignore",
    "content": "dist\nnode_modules\nnpm-debug.log\ncypress/screenshots\n"
  },
  {
    "path": ".npmrc",
    "content": "registry=https://registry.npmjs.org/\r\n"
  },
  {
    "path": ".prettierignore",
    "content": "node_modules\ndist\npackage-lock.json\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n    \"tabWidth\": 4,\n    \"singleQuote\": true,\n    \"printWidth\": 120\n}\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n    - node # Current stable\n    - lts/* # Most recent LTS version\n\ninstall:\n    - npm ci\n\nscript:\n    - npm run test\n    - npm run cypress:run\n\nbranches:\n    only:\n        - master\n        - next\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n\n## [2.2.0](https://github.com/marmelab/gremlins.js/compare/v2.1.1...v2.2.0) (2020-07-21)\n\n### Features\n\n-   add formFiller cypress test ([e278b5b](https://github.com/marmelab/gremlins.js/commit/e278b5bf10eec1ed7e71cae0dc7a641e7971540f))\n-   allow to pass a custom window to gremlins ([9a2084c](https://github.com/marmelab/gremlins.js/commit/9a2084c668f68be3285633e987889839dab190da))\n-   bump standard-version to 8.0.2 ([ed60ec6](https://github.com/marmelab/gremlins.js/commit/ed60ec6b0f1a498479c2eb29205eaaa81a2c5341))\n-   update readme with cypress usage ([005373e](https://github.com/marmelab/gremlins.js/commit/005373efd3cd52427b7220b3c3befe5a3d08053b))\n\n### Bug Fixes\n\n-   bad practice in readme ([d0528ab](https://github.com/marmelab/gremlins.js/commit/d0528ab60b1887c55a5226cf7a6d95b121fdf942))\n-   cypress plugins ([8ec3047](https://github.com/marmelab/gremlins.js/commit/8ec304755a3a8d1ae3d86da688c81b658d8158d3))\n-   linter conf ([22ca500](https://github.com/marmelab/gremlins.js/commit/22ca500d1d0d82e01ada08a800fbea37bc40d6d8))\n-   pass window to gremlins ([9898e41](https://github.com/marmelab/gremlins.js/commit/9898e41d53fe82a4b26145757816e07a754d7da5))\n-   remove useless command in package.json ([c7f3243](https://github.com/marmelab/gremlins.js/commit/c7f3243ee04d49c14efcabc9078c76e82e18ad16))\n-   remove useless fixture ([1166503](https://github.com/marmelab/gremlins.js/commit/11665031ef341d4bee9c5208604c7334bd27c3de))\n-   remove useless make command ([b00e703](https://github.com/marmelab/gremlins.js/commit/b00e703c74f3659246af627adf6476993fc92f70))\n\n### [2.1.1](https://github.com/marmelab/gremlins.js/compare/v2.1.0...v2.1.1) (2020-04-27)\n\n### Bug Fixes\n\n-   add hmtl prototype for numbers elements ([e415936](https://github.com/marmelab/gremlins.js/commit/e4159365515fb1068e6f0a98e4c008e79d7e6653))\n\n## [2.1.0](https://github.com/marmelab/gremlins.js/compare/v2.0.1...v2.1.0) (2020-04-22)\n\n### Features\n\n-   make scroll signal unclickable ([e526549](https://github.com/marmelab/gremlins.js/commit/e52654911dc2c3d7b6d8adb134ba916a6937a938))\n\n### Bug Fixes\n\n-   chance RangeError ([3856336](https://github.com/marmelab/gremlins.js/commit/38563366603c39a759a5df6c04195ffb5217738a))\n\n### [2.0.1](https://github.com/marmelab/gremlins.js/compare/v2.0.0...v2.0.1) (2020-04-08)\n\n## [2.0.0](https://github.com/marmelab/gremlins.js/compare/v2.0.0-next.2...v2.0.0) (2020-04-08)\n\n### Features\n\n-   add customisable bookmarklet ([96db4be](https://github.com/marmelab/gremlins.js/commit/96db4be3608068a0ff56390859d6c2e0c54dce10))\n-   add guide, issue, bug template ([16016df](https://github.com/marmelab/gremlins.js/commit/16016df1219aab461d0a79d2e9fc3059ae286212))\n-   expose gremlins in bookmarklet page ([a03d429](https://github.com/marmelab/gremlins.js/commit/a03d429ad95e87f45889aa2bd0f1db1fc44aef86))\n-   refaco executeInSeries function ([aa03316](https://github.com/marmelab/gremlins.js/commit/aa03316df05419bfa811cda3d4800570dce6ac5b))\n-   update babel and rolup dep ([d6b439b](https://github.com/marmelab/gremlins.js/commit/d6b439b8637d8057673cd61c7b21b091dc8b4fa1))\n-   update readme ([ae11c93](https://github.com/marmelab/gremlins.js/commit/ae11c937f7f3bc92aff61644dca60998df971ca1))\n-   update seed, stop and custom logger documentation ([13c9920](https://github.com/marmelab/gremlins.js/commit/13c99203cf2712248ffceb4cde80d705096c1787))\n-   update to prettier 2.0 and eslint last version ([af374d4](https://github.com/marmelab/gremlins.js/commit/af374d4a5dd5789eacec5d543f6d0fe7ec335e62))\n\n### Bug Fixes\n\n-   change next to master branch ([f66ffeb](https://github.com/marmelab/gremlins.js/commit/f66ffebc20715c386b087f88c35b75e4b0112cf3))\n-   illegal invocation on text area ([a877e46](https://github.com/marmelab/gremlins.js/commit/a877e46245292fa068eb209ed69f6a1f88d5b337))\n-   simulated on change usage ([24ea017](https://github.com/marmelab/gremlins.js/commit/24ea017b0b20e00403adace3caf17df1ea4b416a))\n-   toucher log test ([c7f2abd](https://github.com/marmelab/gremlins.js/commit/c7f2abdbc7c8a870241144d34675de4fa4d7a61f))\n-   typo in readme ([9cbb8e5](https://github.com/marmelab/gremlins.js/commit/9cbb8e553047739e7ff8b77f5f3ce20804afb144))\n-   update babel to fix test on node 13.10.1 ([ffc6542](https://github.com/marmelab/gremlins.js/commit/ffc654235c577d54e69bfbbc02b2b55242525a52))\n-   use fake timers usage ([c404ed8](https://github.com/marmelab/gremlins.js/commit/c404ed81941d361e6fb1845573054336f10a1462))\n\n## [2.0.0-next.2](https://github.com/marmelab/gremlins.js/compare/v2.0.0-next.1...v2.0.0-next.2) (2020-02-26)\n\n### Features\n\n-   add bookmarklet.html file ([96b26a0](https://github.com/marmelab/gremlins.js/commit/96b26a080605d42149afa669447523ff774b5b1a))\n-   deploy to gh-pages ([2399363](https://github.com/marmelab/gremlins.js/commit/2399363ac114037a5292d520eeb55e5883cdaaeb))\n\n### Bug Fixes\n\n-   custom config, logger & exceptions ([fc1ca4b](https://github.com/marmelab/gremlins.js/commit/fc1ca4b7728227f463a4c49706c66f237df24c88))\n\n## [2.0.0-next.1](https://github.com/marmelab/gremlins.js/compare/v2.0.0-next...v2.0.0-next.1) (2020-02-26)\n\n### Features\n\n-   add standard-version package ([137eb96](https://github.com/marmelab/gremlins.js/commit/137eb96e4f635fb6f5a1bc348dce430dfa31c990))\n-   change bundle name to gremlins and fix strategies stop ([6203ed4](https://github.com/marmelab/gremlins.js/commit/6203ed4f34040247672f1e436b19278c84759ecb))\n-   clean up code and use object for config ([a12e779](https://github.com/marmelab/gremlins.js/commit/a12e77983d19f8951261a5dd9e694ae75943694e))\n-   migrate form filler ([f9a7698](https://github.com/marmelab/gremlins.js/commit/f9a7698c88ead3f9b908e57e58f1e45bb2b8a999))\n-   migrate mogwais and delete configurable ([e87de74](https://github.com/marmelab/gremlins.js/commit/e87de74608510a9b8b5c96a3e50ffe6d0fdc9686))\n-   migrate scroller ([72ee515](https://github.com/marmelab/gremlins.js/commit/72ee515ed25a7694c6b9a5d79a67b7ac39619da4))\n-   migrate strategies ([b300076](https://github.com/marmelab/gremlins.js/commit/b3000764f5acf6623e969944152db640868220aa))\n-   migrate toucher ([bbec05c](https://github.com/marmelab/gremlins.js/commit/bbec05c221599d9dbf15628b465f27df45f38c7d))\n-   migrate typer ([50eaa3b](https://github.com/marmelab/gremlins.js/commit/50eaa3b54f3f3763234f153d31aefb5fc0c3886d))\n-   use object config ([7876644](https://github.com/marmelab/gremlins.js/commit/7876644f5d4cac10b4803d6c4c94177b47efe08d))\n\n### Bug Fixes\n\n-   const names ([7d57872](https://github.com/marmelab/gremlins.js/commit/7d578723c447fccc6bd31776601ac407dc73c352))\n-   remove unused parameter from executeInSeries ([a85a9bf](https://github.com/marmelab/gremlins.js/commit/a85a9bf75897f8e3c690981ae19e459b9130de30))\n\n## [2.0.0-next.0](https://github.com/marmelab/gremlins.js/compare/v2.0.0-next...v2.0.0-next.0) (2020-02-26)\n\n### Features\n\n-   add standard-version package ([137eb96](https://github.com/marmelab/gremlins.js/commit/137eb96e4f635fb6f5a1bc348dce430dfa31c990))\n\n## [2.0.0-next](https://github.com/marmelab/gremlins.js/compare/v0.1.0...v2.0.0-next) (2020-02-26)\n\n### Features\n\n-   add commitlint convention ([b1e7d03](https://github.com/marmelab/gremlins.js/commit/b1e7d03aae45de6aa37c26e00fed59bd39600218))\n-   add sourcemap on production build ([275a296](https://github.com/marmelab/gremlins.js/commit/275a2961283ac0adafc45a662cfdc1886696f7ac))\n-   add travis CI ([1d5fc5e](https://github.com/marmelab/gremlins.js/commit/1d5fc5ece866fa1373ca224dde0a431221ba271c))\n-   bootstrap rollup ([677ba03](https://github.com/marmelab/gremlins.js/commit/677ba0318708da2780a1288124dc2d424f5130f1))\n-   bootstrap test with jest ([13398a6](https://github.com/marmelab/gremlins.js/commit/13398a680774e2035d1b9757f24f3999a96ae278))\n-   eslint update dep ([ab83723](https://github.com/marmelab/gremlins.js/commit/ab83723d82bcf423afd06a1f9294ad782a234b52))\n-   update babel, webpack and chance dep ([69b6567](https://github.com/marmelab/gremlins.js/commit/69b6567e4292e9cad2e8614fa7b26d10d58d680b))\n\n# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participation in our\ncommunity a harassment-free experience for everyone, regardless of age, body\nsize, visible or invisible disability, ethnicity, sex characteristics, gender\nidentity and expression, level of experience, education, socio-economic status,\nnationality, personal appearance, race, religion, or sexual identity\nand orientation.\n\nWe pledge to act and interact in ways that contribute to an open, welcoming,\ndiverse, inclusive, and healthy community.\n\n## Our Standards\n\nExamples of behavior that contributes to a positive environment for our\ncommunity include:\n\n-   Demonstrating empathy and kindness toward other people\n-   Being respectful of differing opinions, viewpoints, and experiences\n-   Giving and gracefully accepting constructive feedback\n-   Accepting responsibility and apologizing to those affected by our mistakes,\n    and learning from the experience\n-   Focusing on what is best not just for us as individuals, but for the\n    overall community\n\nExamples of unacceptable behavior include:\n\n-   The use of sexualized language or imagery, and sexual attention or\n    advances of any kind\n-   Trolling, insulting or derogatory comments, and personal or political attacks\n-   Public or private harassment\n-   Publishing others' private information, such as a physical or email\n    address, without their explicit permission\n-   Other conduct which could reasonably be considered inappropriate in a\n    professional setting\n\n## Enforcement Responsibilities\n\nCommunity leaders are responsible for clarifying and enforcing our standards of\nacceptable behavior and will take appropriate and fair corrective action in\nresponse to any behavior that they deem inappropriate, threatening, offensive,\nor harmful.\n\nCommunity leaders have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, and will communicate reasons for moderation\ndecisions when appropriate.\n\n## Scope\n\nThis Code of Conduct applies within all community spaces, and also applies when\nan individual is officially representing the community in public spaces.\nExamples of representing our community include using an official e-mail address,\nposting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported to the community leaders responsible for enforcement at\n[INSERT CONTACT METHOD].\nAll complaints will be reviewed and investigated promptly and fairly.\n\nAll community leaders are obligated to respect the privacy and security of the\nreporter of any incident.\n\n## Enforcement Guidelines\n\nCommunity leaders will follow these Community Impact Guidelines in determining\nthe consequences for any action they deem in violation of this Code of Conduct:\n\n### 1. Correction\n\n**Community Impact**: Use of inappropriate language or other behavior deemed\nunprofessional or unwelcome in the community.\n\n**Consequence**: A private, written warning from community leaders, providing\nclarity around the nature of the violation and an explanation of why the\nbehavior was inappropriate. A public apology may be requested.\n\n### 2. Warning\n\n**Community Impact**: A violation through a single incident or series\nof actions.\n\n**Consequence**: A warning with consequences for continued behavior. No\ninteraction with the people involved, including unsolicited interaction with\nthose enforcing the Code of Conduct, for a specified period of time. This\nincludes avoiding interactions in community spaces as well as external channels\nlike social media. Violating these terms may lead to a temporary or\npermanent ban.\n\n### 3. Temporary Ban\n\n**Community Impact**: A serious violation of community standards, including\nsustained inappropriate behavior.\n\n**Consequence**: A temporary ban from any sort of interaction or public\ncommunication with the community for a specified period of time. No public or\nprivate interaction with the people involved, including unsolicited interaction\nwith those enforcing the Code of Conduct, is allowed during this period.\nViolating these terms may lead to a permanent ban.\n\n### 4. Permanent Ban\n\n**Community Impact**: Demonstrating a pattern of violation of community\nstandards, including sustained inappropriate behavior, harassment of an\nindividual, or aggression toward or disparagement of classes of individuals.\n\n**Consequence**: A permanent ban from any sort of public interaction within\nthe community.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 2.0, available at\nhttps://www.contributor-covenant.org/version/2/0/code_of_conduct.html.\n\nCommunity Impact Guidelines were inspired by [Mozilla's code of conduct\nenforcement ladder](https://github.com/mozilla/diversity).\n\n[homepage]: https://www.contributor-covenant.org\n\nFor answers to common questions about this code of conduct, see the FAQ at\nhttps://www.contributor-covenant.org/faq. Translations are available at\nhttps://www.contributor-covenant.org/translations.\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contribution\n\nYeay! You want to contribute to gremlins.js. That's amazing!\nTo smoothen everyone's experience involved with the project please take note of the following guidelines and rules.\n\n## Found an Issue?\n\nThank you for reporting any issues you find. We do our best to test and make gremlins.js as solid as possible, but any reported issue is a real help.\n\nPlease follow these guidelines when reporting issues:\n\n-   Tag your issue with the tag `bug`\n-   Provide a short summary of what you are trying to do\n-   Provide the log of the encountered error if applicable\n-   Provide the exact version of gremlins.js. Check `npm ls gremlins.js` when in doubt\n-   Be awesome and consider contributing a [pull request](#want-to-contribute)\n\n## Want to contribute?\n\nYou consider contributing changes to gremlins.js – we dig that!\nPlease consider these guidelines when filing a pull request:\n\n-   Follow the [Coding Rules](#coding-rules)\n-   Follow the [Commit Rules](#commit-rules)\n-   Make sure you rebased the current master branch when filing the pull request\n-   Squash your commits when filing the pull request\n-   Provide a short title with a maximum of 100 characters\n-   Provide a more detailed description containing\n    _ What you want to achieve\n    _ What you changed\n    _ What you added\n    _ What you removed\n\n## Coding Rules\n\nTo keep the code base of gremlins.js neat and tidy the following rules apply to every change\n\n-   `eslint` and `prettier` is king, use `make lint` and `make format`\n-   Be awesome\n\n## Commit Rules\n\nTo help everyone with understanding the commit history of gremlins.js the following commit rules are enforced. We follow the [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/) convention in order to automate CHANGELOG generation and to automate semantic versioning.\n\nFor example:\n\n-   `feat: A new feature`\n-   `fix: A bug fix`\n\nCommits types such as as `docs:`,`style:`,`refactor:`,`perf:`,`test:` and `chore:` are valid but have no effect on versioning. **It would be great if you use them.**\n\nAll commits message are going to be validated when they are created using husky hooks.\n\n**PRs that do not follow the commit message guidelines will not be merged.**\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2014 marmelab\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "Makefile",
    "content": "help:\n\t@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = \":.*?## \"}; {printf \"\\033[36m%-30s\\033[0m %s\\n\", $$1, $$2}'\n\ninstall: ## Install dependencies\n\tnpm install\n\nstart: ## Rollup watch the project\n\tnpm run start\n\nbuild: clear ## Rollup build the project\n\tnpm run build\n\nclear: ## Clear dist directory\n\tnpm run clear\n\ntest: ## Run whole tests\n\tnpm run test\n\ntest-cypress: ## Run cypress tests\n\tnpm run cypress:run\n\ntest-watch: ## Watch whole test suites\n\tnpm run test:watch\n\nlint: ## lint the code and check coding conventions\n\techo \"Running linter...\"\n\tnpm run lint\n\nformat: ## prettify the source code using prettier\n\techo \"Running prettier...\"\n\tnpm run format\n\nserve: build ## Serve dist directory\n\tnpm run serve\n\npublish: ## Publish\n\tnpm run release\n\npublish-dry-run: ## Publish dry-run\n\tnpm run release -- --dry-run\n\npublish-next: ## Publish on next tag\n\tnpm run release -- --prerelease next\n\ndeploy-gh-pages: ## Deploy bookmaklet to gh-pages\n\tnpm run deploy-gh-pages\n"
  },
  {
    "path": "README.md",
    "content": "<div align=\"center\">\n<h1>gremlins.js</h1>\n\n<img\n    height=\"80\"\n    width=\"80\"\n    alt=\"gremlins\"\n    src=\"https://raw.githubusercontent.com/marmelab/gremlins.js/master/other/gremlins.png\"\n/>\n\n<p>A monkey testing library written in JavaScript, for Node.js and the browser. Use it to check the robustness of web applications by unleashing a horde of undisciplined gremlins.</p>\n\n<br />\n\n[**Generate bookmarklet**](https://marmelab.com/gremlins.js/) | [Install docs](#Installation)\n\n<br />\n</div>\n\n<hr />\n\n[![version](https://img.shields.io/npm/v/gremlins.js.svg?style=flat-square)](https://www.npmjs.com/package/gremlins.js)\n[![downloads](https://img.shields.io/npm/dm/gremlins.js.svg?style=flat-square)](https://www.npmtrends.com/gremlins.js)\n[![Build Status](https://img.shields.io/travis/marmelab/gremlins.js.svg?style=flat-square)](https://travis-ci.org/github/marmelab/gremlins.js)\n\n[![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](https://github.com/marmelab/gremlins.js/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc)\n[![Code of Conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](https://github.com/marmelab/gremlins.js/blob/master/code_of_conduct.md)\n[![MIT License](https://img.shields.io/npm/l/gremlins.js.svg?style=flat-square)](https://github.com/marmelab/gremlins.js/blob/master/license)\n\n[![Tweet](https://img.shields.io/twitter/url/https/github.com/marmelab/gremlins.js.svg?style=social)](https://twitter.com/intent/tweet?text=check%20out%20gremlins.js%20by%20%40marmelab%20https%3a%2f%2fgithub.com%2fmarmelab%2fgremlins.js%20%f0%9f%91%8d)\n\n<div align=\"center\">\n<img\n    width=\"500\"\n    alt=\"TodoMVC attacked by gremlins\"\n    src=\"http://static.marmelab.com/todo.gif\"\n/>\n</div>\n\n> Kate: _What are they, Billy?_\n>\n> Billy Peltzer: _They're gremlins, Kate, just like Mr. Futterman said._\n\n## Table of Contents\n\n<!-- prettier-ignore-start -->\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n\n- [Purpose](#purpose)\n- [Installation](#installation)\n- [Basic Usage](#basic-usage)\n- [Advanced Usage](#advanced-usage)\n  - [Setting Gremlins and Mogwais To Use In A Test](#setting-gremlins-and-mogwais-to-use-in-a-test)\n  - [Configuring Gremlins](#configuring-gremlins)\n  - [Seeding The Randomizer](#seeding-the-randomizer)\n  - [Executing Code Before or After The Attack](#executing-code-before-or-after-the-attack)\n  - [Setting Up a Strategy](#setting-up-a-strategy)\n  - [Stopping The Attack](#stopping-the-attack)\n  - [Customizing The Logger](#customizing-the-logger)\n  - [Cypress](#cypress)\n  - [Playwright](#playwright)\n- [Docs](#docs)\n  - [Issues](#issues)\n  - [🐛 Bugs](#-bugs)\n  - [💡 Feature Requests](#-feature-requests)\n- [License](#license)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n<!-- prettier-ignore-end -->\n\n## Purpose\n\nWhile developing an HTML5 application, did you anticipate uncommon user interactions? Did you manage to detect and patch all memory leaks? If not, the application may break sooner or later. If n random actions can make an application fail, it's better to acknowledge it during testing, rather than letting users discover it.\n\nGremlins.js simulates random user actions: gremlins click anywhere in the window, enter random data in forms, or move the mouse over elements that don't expect it. Their goal: triggering JavaScript errors, or making the application fail. If gremlins can't break an application, congrats! The application is robust enough to be released to real users.\n\nThis practice, also known as [Monkey testing](http://en.wikipedia.org/wiki/Monkey_test) or [Fuzz testing](http://en.wikipedia.org/wiki/Fuzz_testing), is very common in mobile application development (see for instance the [Android Monkey program](http://developer.android.com/tools/help/monkey.html)). Now that frontend (MV\\*, d3.js, Backbone.js, Angular.js, etc.) and backend (Node.js) development use persistent JavaScript applications, this technique becomes valuable for web applications.\n\n## Installation\n\nThis module is distributed via [npm](https://www.npmjs.com/) which is bundled with [node](https://nodejs.org/en/) and should be installed as one of your project's `dependencies`:\n\n```\nnpm i gremlins.js\n```\n\nThis library has `dependencies` listings for `chance`.\n\n`gremlins.js` is also available as a **bookmarklet**. Go to [this page](https://marmelab.com/gremlins.js/), grab it, and unleash hordes on any web page.\n\n## Basic Usage\n\nA gremlins _horde_ is an army of specialized gremlins ready to mess up your application. _unleash_ the gremlins to start the stress test:\n\n```js\nconst horde = gremlins.createHorde();\nhorde.unleash();\n// gremlins will act randomly, at 10 ms interval, 1000 times\n```\n\n`gremlins.js` provides several gremlin _species_: some click everywhere on the page, others enter data in form inputs, others scroll the window in every possible direction, etc.\n\nYou will see traces of the gremlins actions on the screen (they leave red traces) and in the console log:\n\n```\ngremlin formFiller input 5 in <input type=​\"number\" name=​\"age\">​\ngremlin formFiller input pzdoyzshh0k9@o8cpskdb73nmi.r7r in <input type=​\"email\" name=​\"email\">​\ngremlin clicker    click at 1219 301\ngremlin scroller   scroll to 100 25\n...\n```\n\nA horde also contains _mogwais_, which are harmless gremlins (or, you could say that gremlins are harmful mogwais). Mogwais only monitor the activity of the application and record it on the logger. For instance, the \"fps\" mogwai monitors the number of frame per second, every 500ms:\n\n```\nmogwai  fps  33.21\nmogwai  fps  59.45\nmogwai  fps  12.67\n...\n```\n\nMogwais also report when gremlins break the application. For instance, if the number of frames per seconds drops below 10, the fps mogwai will log an error:\n\n```\nmogwai  fps  12.67\nmogwai  fps  23.56\nerr > mogwai  fps  7.54 < err\nmogwai  fps  15.76\n...\n```\n\nAfter 10 errors, a special mogwai stops the test. He's called _Gizmo_, and he prevents gremlins from breaking applications bad. After all, once gremlins have found the first 10 errors, you already know what you have to do to make your application more robust.\n\nIf not stopped by Gizmo, the default horde stops after roughly 1 minute. You can increase the number of gremlins actions to make the attack last longer:\n\n```js\nconst horde = gremlins.createHorde({\n    strategies: [gremlins.strategies.allTogether({ nb: 10000 })],\n});\nhorde.unleash();\n// gremlins will attack at 10 ms interval, 10,000 times\n```\n\nGremlins, just like mogwais, are simple JavaScript functions. If `gremlins.js` doesn't provide the gremlin that can break your application, it's very easy to develop it:\n\n```js\n// Create a new custom gremlin to blur an input randomly selected\nfunction customGremlin({ logger, randomizer, window }) {\n    // Code executed once at initialization\n    logger.log('Input blur gremlin initialized');\n    // Return a function that will be executed at each attack\n    return function attack() {\n        var inputs = document.querySelectorAll('input');\n        var element = randomizer.pick(element);\n        element.blur();\n        window.alert('attack done');\n    };\n}\n\n// Add it to your horde\nconst horde = gremlins.createHorde({\n    species: [customGremlin],\n});\n```\n\nEverything in `gremlins.js` is configurable ; you will find it very easy to extend and adapt to you use cases.\n\n## Advanced Usage\n\n### Setting Gremlins and Mogwais To Use In A Test\n\nBy default, all gremlins and mogwais species are added to the horde.\n\nYou can also choose to add only the gremlins species you want, using a custom configuration object:\n\n```js\ngremlins\n    .createHorde({\n        species: [\n            gremlins.species.formFiller(),\n            gremlins.species.clicker({\n                clickTypes: ['click'],\n            }),\n            gremlins.species.toucher(),\n        ],\n    })\n    .unleash();\n```\n\nIf you just want to add your own gremlins in addition to the default ones, use the `allSpecies` constant:\n\n```js\ngremlins\n    .createHorde({\n        species: [...gremlins.allSpecies, customGremlin],\n    })\n    .unleash();\n```\n\nTo add just the mogwais you want, use the `mogwai` configuration and `allMogwais()` constant the same way.\n\n`gremlins.js` currently provides a few gremlins and mogwais:\n\n-   [clickerGremlin](src/species/clicker.js) clicks anywhere on the visible area of the document\n-   [toucherGremlin](src/species/toucher.js) touches anywhere on the visible area of the document\n-   [formFillerGremlin](src/species/formFiller.js) fills forms by entering data, selecting options, clicking checkboxes, etc\n-   [scrollerGremlin](src/species/scroller.js) scrolls the viewport to reveal another part of the document\n-   [typerGremlin](src/species/typer.js) types keys on the keyboard\n-   [alertMogwai](src/mogwais/alert.js) prevents calls to alert() from blocking the test\n-   [fpsMogwai](src/mogwais/fps.js) logs the number of frames per seconds (FPS) of the browser\n-   [gizmoMogwai](src/mogwais/gizmo.js) can stop the gremlins when they go too far\n\n### Configuring Gremlins\n\nAll the gremlins and mogwais provided by `gremlins.js` are _configurable_, i.e. you can alter the way they work by injecting a custom configuration.\n\nFor instance, the clicker gremlin is a function that take an object as custom configuration:\n\n```js\nconst customClicker = gremlins.species.clicker({\n    // which mouse event types will be triggered\n    clickTypes: ['click'],\n    // Click only if parent is has class test-class\n    canClick: (element) => element.parentElement.className === 'test-class',\n    // by default, the clicker gremlin shows its action by a red circle\n    // overriding showAction() with an empty function makes the gremlin action invisible\n    showAction: (x, y) => {},\n});\ngremlins.createHorde({\n    species: [customClicker],\n});\n```\n\nEach particular gremlin or mogwai has its own customization methods, check the source for details.\n\n### Seeding The Randomizer\n\nIf you want the attack to be repeatable, you need to seed the random number generator :\n\n```js\n// seed the randomizer\nhorde.createHorde({\n    randomizer: new gremlins.Chance(1234);\n});\n```\n\n### Executing Code Before or After The Attack\n\nBefore starting the attack, you may want to execute custom code. This is especially useful to:\n\n-   Start a profiler\n-   Disable some features to better target the test\n-   Bootstrap the application\n\nFortunately, `unleashHorde` is a Promise. So if you want to execute code before and after the unleash just do:\n\n```js\nconst horde = gremlins.createHorde();\n\nconsole.profile('gremlins');\nhorde.unleash().then(() => {\n    console.profileEnd();\n});\n```\n\n### Setting Up a Strategy\n\nBy default, gremlins will attack in random order, in a uniform distribution, separated by a delay of 10ms. This attack strategy is called the [distribution](src/strategies/distribution.js) strategy. You can customize it using the strategies custom object:\n\n```js\nconst distributionStrategy = gremlins.strategies.distribution({\n    distribution: [0.3, 0.3, 0.3, 0.1], // the first three gremlins have more chances to be executed than the last\n    delay: 50, // wait 50 ms between each action\n});\n```\n\nNote that if using default gremlins, there are [five type of gremlins](https://github.com/marmelab/gremlins.js/blob/master/src/index.js#L52). The previous example would give a 0 value to last gremlin specie.\n\nYou can also use another strategy. A strategy is just a function expecting one parameter: an array of gremlins. Two other strategies are bundled ([allTogether](src/strategies/allTogether.js) and [bySpecies](src/strategies/bySpecies.js)), and it should be fairly easy to implement a custom strategy for more sophisticated attack scenarios.\n\n### Stopping The Attack\n\nThe horde can stop the attack in case of emergency using the `horde.stop()` method Gizmo uses this method to prevent further damages to the application after 10 errors, and you can use it, too, if you don't want the attack to continue.\n\n### Customizing The Logger\n\nBy default, gremlins.js logs all gremlin actions and mogwai observations in the console. If you prefer using an alternative logging method (for instance, storing gremlins activity in LocalStorage and sending it in Ajax once every 10 seconds), just provide a logger object with 4 methods (log, info, warn, and error) to the `logger()` method:\n\n```js\nconst customLogger = {\n    log: function (msg) {\n        /* .. */\n    },\n    info: function (msg) {\n        /* .. */\n    },\n    warn: function (msg) {\n        /* .. */\n    },\n    error: function (msg) {\n        /* .. */\n    },\n};\nhorde.createHorde({ logger: customLogger });\n```\n\n### Cypress\n\nTo run gremlins.js inside a cypress test, you need to provide the tested window:\n\n```js\nimport { createHorde } from 'gremlins.js';\n\ndescribe('Run gremlins.js inside a cypress test', () => {\n    let horde;\n    beforeEach(() =>\n        cy.window().then((testedWindow) => {\n            horde = createHorde({ window: testedWindow });\n        })\n    );\n    it('should run gremlins.js', () => {\n        return cy.wrap(horde.unleash()).then(() => {\n            /* ... */\n        });\n    });\n});\n```\n\n### Playwright\n\nTo run gremlin.js with Playwright, you can load it as an init script.\n\n```js\nconst { test } = require('@playwright/test');\n\ntest('run gremlins.js', async ({ page }) => {\n    await page.addInitScript({\n        path: './node_modules/gremlins.js/dist/gremlins.min.js',\n    });\n    await page.goto('https://playwright.dev');\n    await page.evaluate(() => gremlins.createHorde().unleash());\n});\n```\n\n## Docs\n\n### Issues\n\n_Looking to contribute? Look for the [Good First Issue](https://github.com/marmelab/gremlins.js/issues?q=is%3aissue+is%3aopen+sort%3areactions-%2b1-desc)\nlabel._\n\n### 🐛 Bugs\n\nPlease file an issue for bugs, missing documentation, or unexpected behavior.\n\n[**See Bugs**](https://github.com/marmelab/gremlins.js/issues?q=is%3aissue+is%3aopen+label%3abug+sort%3acreated-desc)\n\n### 💡 Feature Requests\n\nPlease file an issue to suggest new features. Vote on feature requests by adding\na 👍. This helps maintainers prioritize what to work on.\n\n[**See Feature Requests**](https://github.com/marmelab/gremlins.js/issues?q=is%3aissue+sort%3areactions-%2b1-desc+label%3aenhancement+is%3aopen)\n\n## License\n\ngremlins.js is licensed under the [MIT Licence](LICENSE), courtesy of [marmelab](http://marmelab.com).\n"
  },
  {
    "path": "bookmarklet/index.css",
    "content": "body {\n    display: grid;\n    grid-template-columns: repeat(2, 1fr);\n    gap: 20px;\n}\n\n.bookmarklet {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: space-between;\n}\n\n.form {\n    display: flex;\n    justify-content: space-between;\n    margin-bottom: 20px;\n    width: 100%;\n}\n\n.bookmarklet-container {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n}\n.code-container {\n    background-color: antiquewhite;\n}\n\n.code {\n    white-space: pre-wrap;\n    color: darkslategrey;\n}\n\n.code-title {\n    text-align: center;\n}\n"
  },
  {
    "path": "bookmarklet/index.html",
    "content": "<html>\n    <head>\n        <title>Gremlins.js Bookmarklet</title>\n        <link rel=\"stylesheet\" type=\"text/css\" href=\"index.css\" />\n    </head>\n    <body>\n        <div class=\"bookmarklet\">\n            <form id=\"gremlins-form\" class=\"form\">\n                <div>\n                    <h2>Species</h2>\n                    <div>\n                        <input id=\"clicker\" name=\"clicker\" type=\"checkbox\" checked />\n                        <label for=\"clicker\">Clicker</label>\n                    </div>\n                    <div>\n                        <input id=\"toucher\" name=\"toucher\" type=\"checkbox\" checked />\n                        <label for=\"toucher\">Toucher</label>\n                    </div>\n                    <div>\n                        <input id=\"formFiller\" name=\"formFiller\" type=\"checkbox\" checked />\n                        <label for=\"formFiller\">Form Filler</label>\n                    </div>\n                    <div>\n                        <input id=\"scroller\" name=\"scroller\" type=\"checkbox\" checked />\n                        <label for=\"scroller\">Scroller</label>\n                    </div>\n                    <div>\n                        <input id=\"typer\" name=\"typer\" type=\"checkbox\" checked />\n                        <label for=\"typer\">Typer</label>\n                    </div>\n                </div>\n                <div>\n                    <h2>Mogwais</h2>\n                    <div>\n                        <input id=\"alert\" name=\"alert\" type=\"checkbox\" checked />\n                        <label for=\"alert\">Alert</label>\n                    </div>\n                    <div>\n                        <input id=\"fps\" name=\"fps\" type=\"checkbox\" checked />\n                        <label for=\"fps\">Fps</label>\n                    </div>\n                    <div>\n                        <input id=\"gizmo\" name=\"gizmo\" type=\"checkbox\" checked />\n                        <label for=\"gizmo\">Gizmo</label>\n                    </div>\n                </div>\n                <div>\n                    <h2>Strategies</h2>\n                    <div>\n                        <input id=\"distribution\" name=\"distribution\" type=\"checkbox\" checked />\n                        <label for=\"distribution\">Distribution</label>\n                    </div>\n                    <div>\n                        <input id=\"allTogether\" name=\"allTogether\" type=\"checkbox\" />\n                        <label for=\"allTogether\">All Together</label>\n                    </div>\n                    <div>\n                        <input id=\"bySpecies\" name=\"bySpecies\" type=\"checkbox\" />\n                        <label for=\"bySpecies\">By Species</label>\n                    </div>\n                </div>\n            </form>\n\n            <div class=\"bookmarklet-container\">\n                <p>Drag and drop the link below to your bookmarks toolbar</p>\n                <a id=\"bookmarklet\" title=\"gremlins.js\">gremlins.js</a>\n            </div>\n        </div>\n        <div class=\"code-container\">\n            <h2 class=\"code-title\">Bookmarklet Code</h2>\n            <p id=\"code\" class=\"code\"></p>\n        </div>\n    </body>\n</html>\n\n<script>\n    function setBookmarkletScript() {\n        const speciesNames = ['clicker', 'toucher', 'formFiller', 'scroller', 'typer'];\n        const mogwaisNames = ['alert', 'fps', 'gizmo'];\n        const strategiesNames = ['distribution', 'allTogether', 'bySpecies'];\n        const species = speciesNames\n            .map(name => {\n                const isActive = document.getElementById(name).checked;\n                return isActive ? `gremlins.species.${name}()` : null;\n            })\n            .filter(value => value)\n            .join(',');\n\n        const mogwais = mogwaisNames\n            .map(name => {\n                const isActive = document.getElementById(name).checked;\n                return isActive ? `gremlins.mogwais.${name}()` : null;\n            })\n            .filter(value => value)\n            .join(',');\n\n        const strategies = strategiesNames\n            .map(name => {\n                const isActive = document.getElementById(name).checked;\n                return isActive ? `gremlins.strategies.${name}()` : null;\n            })\n            .filter(value => value)\n            .join(',');\n\n        const script = `\n    javascript: (function() {\n    function callback() {\n        gremlins.createHorde({\n            species: [${species}],\n            mogwais: [${mogwais}],\n            strategies: [${strategies}]\n        }).unleash();\n    }\n    var s = document.createElement(\"script\");\n    s.src = \"https://unpkg.com/gremlins.js\";\n    if (s.addEventListener) {\n        s.addEventListener(\"load\", callback, false);\n    } else if (s.readyState) {\n        s.onreadystatechange = callback;\n    }\n    document.body.appendChild(s);\n    })()`;\n\n        document.getElementById('code').innerHTML = script;\n        document.getElementById('bookmarklet').href = script.replace(/\\s\\s+/g, ' ');\n    }\n\n    function displayExposedGremlins () {\n        console.log(`Gremlins is available in your Console. Try gremlins.createHorde().unleash() to unleash the horde !`);\n    }\n\n    function exposeGremlins() {\n        const script = document.createElement(\"script\");\n        script.type = \"text/javascript\";\n        script.src = \"https://unpkg.com/gremlins.js\";\n        script.addEventListener('load', displayExposedGremlins, false)\n        document.body.appendChild(script);\n    }\n\n    document.getElementById('gremlins-form').addEventListener('input', setBookmarkletScript);\n\n    exposeGremlins();\n    setBookmarkletScript();\n</script>\n"
  },
  {
    "path": "cypress/fixtures/example.json",
    "content": ""
  },
  {
    "path": "cypress/integration/formFiller.spec.js",
    "content": "import Chance from 'chance';\nimport { createHorde, species, strategies } from '../../src/index';\n\nconst seed = 'formFiller';\n\ndescribe('Form filler', () => {\n    let horde;\n    beforeEach(() => {\n        return cy.visit('formFiller.html').then(() =>\n            cy.window().then((pageWindow) => {\n                horde = createHorde({\n                    species: [species.formFiller()],\n                    strategies: [strategies.bySpecies({ nb: 10 })],\n                    window: pageWindow,\n                    randomizer: new Chance(seed),\n                });\n            })\n        );\n    });\n    it('should fill text input with seeded value', () => {\n        return cy.wrap(horde.unleash()).then(() => {\n            cy.get('input[type=\"text\"]').should('have.value', '7uv');\n        });\n    });\n    it('should fill number input with seeded value', () => {\n        return cy.wrap(horde.unleash()).then(() => {\n            cy.get('input[type=\"number\"]').should('have.value', '693');\n        });\n    });\n    it('should fill email input with seeded value', () => {\n        return cy.wrap(horde.unleash()).then(() => {\n            cy.get('input[type=\"email\"]').should('have.value', 'ul@codipo.vn');\n        });\n    });\n});\n"
  },
  {
    "path": "cypress/pages/formFiller.html",
    "content": "<!DOCTYPE html>\n\n<html>\n    <body>\n        <input type=\"text\" />\n        <input type=\"number\" />\n        <input type=\"email\" />\n    </body>\n</html>\n"
  },
  {
    "path": "cypress/plugins/index.js",
    "content": "module.exports = function () {\n    // configure plugins here\n};\n"
  },
  {
    "path": "cypress/support/commands.js",
    "content": "// Overwrite cy.visit to visit local html files\nCypress.Commands.overwrite('visit', (visit, path, options = {}) => visit(`./cypress/pages/${path}`, options));\n"
  },
  {
    "path": "cypress/support/index.js",
    "content": "import './commands';\n"
  },
  {
    "path": "cypress.json",
    "content": "{\n    \"defaultCommandTimeout\": 10000,\n    \"video\": false\n}\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = {\n    roots: ['<rootDir>/src'],\n    resetMocks: true,\n    resetModules: true,\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"gremlins.js\",\n    \"version\": \"2.2.0\",\n    \"description\": \"A monkey testing library written in JavaScript, for Node.js and the browser. Use it to check the robustness of web applications by unleashing a horde of undisciplined gremlins.\",\n    \"main\": \"dist/gremlins.min.js\",\n    \"files\": [\n        \"dist\"\n    ],\n    \"scripts\": {\n        \"start\": \"rollup -c -w\",\n        \"build\": \"cross-env NODE_ENV=production rollup -c\",\n        \"test\": \"cross-env NODE_ENV=test jest\",\n        \"test:watch\": \"cross-env NODE_ENV=test jest --watch\",\n        \"lint\": \"eslint .\",\n        \"format\": \"prettier --write --check \\\"**/*.+(js|json|md)\\\"\",\n        \"serve\": \"serve dist\",\n        \"clear\": \"rimraf dist\",\n        \"release\": \"standard-version\",\n        \"deploy-gh-pages\": \"gh-pages --dist bookmarklet\",\n        \"doctoc\": \"doctoc README.md\",\n        \"cypress:open\": \"cypress open\",\n        \"cypress:run\": \"cypress run\"\n    },\n    \"repository\": {\n        \"type\": \"git\",\n        \"url\": \"https://github.com/marmelab/gremlins.js\"\n    },\n    \"keywords\": [\n        \"monkey\",\n        \"test\",\n        \"testing\",\n        \"stress\",\n        \"gremlin\"\n    ],\n    \"author\": \"Francois Zaninotto\",\n    \"license\": \"MIT\",\n    \"bugs\": {\n        \"url\": \"https://github.com/marmelab/gremlins.js/issues\"\n    },\n    \"homepage\": \"https://github.com/marmelab/gremlins.js\",\n    \"devDependencies\": {\n        \"@babel/core\": \"^7.9.0\",\n        \"@babel/preset-env\": \"^7.9.5\",\n        \"@commitlint/cli\": \"^8.3.5\",\n        \"@commitlint/config-conventional\": \"^8.3.4\",\n        \"@rollup/plugin-commonjs\": \"^11.0.2\",\n        \"@rollup/plugin-node-resolve\": \"^7.1.1\",\n        \"babel-eslint\": \"^10.1.0\",\n        \"babel-jest\": \"^25.3.0\",\n        \"cross-env\": \"^7.0.2\",\n        \"cypress\": \"^4.10.0\",\n        \"doctoc\": \"^1.4.0\",\n        \"eslint\": \"^6.8.0\",\n        \"eslint-config-prettier\": \"^6.10.1\",\n        \"eslint-plugin-babel\": \"^5.3.0\",\n        \"eslint-plugin-cypress\": \"^2.11.1\",\n        \"eslint-plugin-import\": \"^2.20.2\",\n        \"eslint-plugin-jest\": \"^23.8.2\",\n        \"eslint-plugin-prettier\": \"^3.1.2\",\n        \"gh-pages\": \"^2.2.0\",\n        \"husky\": \"^4.2.3\",\n        \"jest\": \"^25.3.0\",\n        \"lint-staged\": \"^10.1.2\",\n        \"prettier\": \"^2.0.4\",\n        \"rimraf\": \"^3.0.2\",\n        \"rollup\": \"^2.3.4\",\n        \"rollup-plugin-babel\": \"^4.4.0\",\n        \"rollup-plugin-commonjs\": \"^10.1.0\",\n        \"rollup-plugin-terser\": \"^5.3.0\",\n        \"serve\": \"^11.3.0\",\n        \"standard-version\": \"^8.0.2\"\n    },\n    \"dependencies\": {\n        \"chance\": \"^1.1.4\",\n        \"core-js\": \"^3.6.4\"\n    },\n    \"husky\": {\n        \"hooks\": {\n            \"pre-commit\": \"lint-staged\",\n            \"commit-msg\": \"commitlint -E HUSKY_GIT_PARAMS\"\n        }\n    },\n    \"lint-staged\": {\n        \"*.js\": \"eslint\",\n        \"*.{js,json,md}\": \"prettier --write\",\n        \"README.md\": \"npm run doctoc\"\n    },\n    \"commitlint\": {\n        \"extends\": [\n            \"@commitlint/config-conventional\"\n        ]\n    }\n}\n"
  },
  {
    "path": "rollup.config.js",
    "content": "import commonjs from '@rollup/plugin-commonjs';\nimport babel from 'rollup-plugin-babel';\nimport { terser } from 'rollup-plugin-terser';\nimport resolve from '@rollup/plugin-node-resolve';\n\nimport pkg from './package.json';\n\nconst isProduction = process.env.NODE_ENV === 'production';\n\nconst umd = [\n    {\n        input: 'src/index.js',\n        output: {\n            name: 'gremlins',\n            file: pkg.main,\n            format: 'umd',\n            sourcemap: isProduction,\n        },\n        plugins: [\n            resolve(),\n            commonjs(),\n            babel({\n                exclude: /node_modules/,\n                sourceMaps: isProduction,\n            }),\n            isProduction && terser(),\n        ],\n    },\n];\n\nexport default umd;\n"
  },
  {
    "path": "src/index.js",
    "content": "import Chance from 'chance';\n\nimport clicker from './species/clicker';\nimport toucher from './species/toucher';\nimport formFiller from './species/formFiller';\nimport scroller from './species/scroller';\nimport typer from './species/typer';\n\nimport alert from './mogwais/alert';\nimport fps from './mogwais/fps';\nimport gizmo from './mogwais/gizmo';\n\nimport distribution from './strategies/distribution';\nimport bySpecies from './strategies/bySpecies';\nimport allTogether from './strategies/allTogether';\n\nimport executeInSeries from './utils/executeInSeries';\n\nconst defaultConfig = {\n    species: [clicker(), formFiller(), toucher(), scroller(), typer()],\n    mogwais: [fps(), alert(), gizmo()],\n    strategies: [distribution()],\n    logger: console,\n    randomizer: new Chance(),\n    window: window,\n};\n\nexport const createHorde = (userConfig) => {\n    const config = { ...defaultConfig, ...userConfig };\n    const { logger, randomizer, window } = config;\n\n    const speciesConfig = {\n        logger,\n        randomizer,\n        window,\n    };\n    const species = config.species.map((specie) => specie(speciesConfig));\n    const strategies = config.strategies.map((strat) => strat(randomizer));\n    const stop = () => strategies.forEach((strat) => strat.stop());\n    const mogwaisConfig = {\n        ...speciesConfig,\n        stop,\n    };\n    const mogwais = config.mogwais.map((mogwai) => mogwai(mogwaisConfig));\n\n    const unleash = async () => {\n        const beforeHorde = [...mogwais];\n        const cleansUps = mogwais.map((mogwai) => mogwai.cleanUp).filter((cleanUp) => typeof cleanUp === 'function');\n\n        await executeInSeries(beforeHorde, []);\n        const unleashedStrategies = strategies.map((strat) => strat(species));\n        await Promise.all(unleashedStrategies);\n        await executeInSeries(cleansUps, []);\n    };\n\n    return {\n        unleash,\n        stop,\n    };\n};\n\nexport const species = { clicker, toucher, formFiller, scroller, typer };\nexport const allSpecies = Object.values(species).map((specie) => specie());\nexport const mogwais = { alert, fps, gizmo };\nexport const allMogwais = Object.values(mogwais).map((mogwai) => mogwai());\nexport const strategies = { distribution, bySpecies, allTogether };\nexport { default as Chance } from 'chance';\n"
  },
  {
    "path": "src/mogwais/alert.js",
    "content": "const getDefaultConfig = (randomizer) => {\n    const defaultWatchEvents = ['alert', 'confirm', 'prompt'];\n\n    const defaultConfirmResponse = () => {\n        return randomizer.bool();\n    };\n\n    const defaultPromptResponse = () => {\n        return randomizer.sentence();\n    };\n\n    return {\n        watchEvents: defaultWatchEvents,\n        confirmResponse: defaultConfirmResponse,\n        promptResponse: defaultPromptResponse,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const config = { ...getDefaultConfig(randomizer), ...userConfig };\n\n    const alert = window.alert;\n    const confirm = window.confirm;\n    const prompt = window.prompt;\n\n    const alertMogwai = () => {\n        if (!logger) {\n            return;\n        }\n        if (config.watchEvents.includes('alert')) {\n            window.alert = (msg) => {\n                logger.warn('mogwai ', 'alert ', msg, 'alert');\n            };\n        }\n        if (config.watchEvents.includes('confirm')) {\n            window.confirm = (msg) => {\n                config.confirmResponse();\n                logger.warn('mogwai ', 'alert ', msg, 'confirm');\n            };\n        }\n        if (config.watchEvents.includes('prompt')) {\n            window.prompt = (msg) => {\n                config.promptResponse();\n                logger.warn('mogwai ', 'alert ', msg, 'prompt');\n            };\n        }\n    };\n\n    alertMogwai.cleanUp = () => {\n        window.alert = alert;\n        window.confirm = confirm;\n        window.prompt = prompt;\n        return alertMogwai;\n    };\n\n    return alertMogwai;\n};\n"
  },
  {
    "path": "src/mogwais/alert.spec.js",
    "content": "import alert from './alert';\n\ndescribe('alert', () => {\n    const chanceBoolMock = jest.fn();\n    const chanceSentenceMock = jest.fn();\n    let config;\n    let consoleMock;\n    let chanceMock;\n\n    beforeEach(() => {\n        consoleMock = { warn: jest.fn() };\n        chanceMock = {\n            bool: chanceBoolMock,\n            sentence: chanceSentenceMock,\n        };\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    it('should call logger warn when window.alert is call', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.alert('new alert');\n\n        expect(consoleMock.warn).toHaveBeenCalledTimes(1);\n        expect(consoleMock.warn).toHaveBeenCalledWith('mogwai ', 'alert ', 'new alert', 'alert');\n    });\n\n    it('should call logger warn when window.confirm is call', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.confirm('new confirm');\n\n        expect(consoleMock.warn).toHaveBeenCalledTimes(1);\n        expect(consoleMock.warn).toHaveBeenCalledWith('mogwai ', 'alert ', 'new confirm', 'confirm');\n    });\n\n    it('should call logger warn when window.prompt is call', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.prompt('new prompt');\n\n        expect(consoleMock.warn).toHaveBeenCalledTimes(1);\n        expect(consoleMock.warn).toHaveBeenCalledWith('mogwai ', 'alert ', 'new prompt', 'prompt');\n    });\n\n    it('should call randomize bool when window.confirm is call', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.confirm('new confirm');\n\n        expect(chanceBoolMock).toHaveBeenCalledTimes(1);\n    });\n\n    it('should call randomize sentence when window.prompt is call', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.prompt('new prompt');\n\n        expect(chanceSentenceMock).toHaveBeenCalledTimes(1);\n    });\n\n    it('should cleanup the window prop when cleanUp function is call', () => {\n        jest.spyOn(window, 'alert').mockImplementation();\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.alert('new alert');\n\n        expect(consoleMock.warn).toHaveBeenCalledTimes(1);\n\n        mogwais.cleanUp();\n\n        window.alert('new alert');\n        expect(consoleMock.warn).toHaveBeenCalledTimes(1);\n    });\n\n    it('should not override the window object when logger is not defined ', () => {\n        const mogwais = alert()(config);\n\n        mogwais();\n        window.alert('new alert');\n\n        expect(chanceSentenceMock).toHaveBeenCalledTimes(0);\n    });\n});\n"
  },
  {
    "path": "src/mogwais/fps.js",
    "content": "const NEXT_FRAME_MS = 16;\n\nconst getDefaultConfig = () => {\n    const defaultLevelSelector = (fps) => {\n        if (fps < 10) return 'error';\n        if (fps < 20) return 'warn';\n        return 'log';\n    };\n    return {\n        delay: 500, // how often should the fps be measured\n        levelSelector: defaultLevelSelector,\n    };\n};\n\nexport default (userConfig) => ({ logger, window }) => {\n    const config = { ...getDefaultConfig(), ...userConfig };\n\n    let initialTime = -Infinity; // force initial measure\n    let enabled;\n\n    const loop = (time) => {\n        if (time - initialTime > config.delay) {\n            measureFPS(time);\n            initialTime = time;\n        }\n        if (!enabled) return;\n        window.requestAnimationFrame(loop);\n    };\n\n    const measureFPS = () => {\n        let lastTime;\n        const init = (time) => {\n            lastTime = time;\n            window.requestAnimationFrame(measure);\n        };\n        const measure = (time) => {\n            const fps = time - lastTime < NEXT_FRAME_MS ? 60 : 1000 / (time - lastTime);\n            const level = config.levelSelector(fps);\n            if (logger) {\n                logger[level]('mogwai ', 'fps       ', fps);\n            }\n        };\n        window.requestAnimationFrame(init);\n    };\n\n    const fpsMogwai = () => {\n        enabled = true;\n        window.requestAnimationFrame(loop);\n    };\n\n    fpsMogwai.cleanUp = () => {\n        enabled = false;\n        return fpsMogwai;\n    };\n\n    return fpsMogwai;\n};\n"
  },
  {
    "path": "src/mogwais/fps.spec.js",
    "content": "import fps from './fps';\n\ndescribe('fps', () => {\n    let consoleMock;\n    let config;\n    let time;\n\n    beforeEach(() => {\n        consoleMock = { warn: jest.fn() };\n\n        time = 0;\n        jest.spyOn(window, 'requestAnimationFrame').mockImplementation((cb) => {\n            time += 100;\n            if (time < 1000) {\n                return cb(time);\n            }\n        });\n        config = {\n            logger: consoleMock,\n            window,\n        };\n    });\n\n    it('should log two times the fps mogwais', async () => {\n        const mogwais = fps()(config);\n\n        mogwais();\n        mogwais.cleanUp();\n\n        expect(consoleMock.warn).toHaveBeenCalledTimes(2);\n        expect(consoleMock.warn).toHaveBeenNthCalledWith(1, 'mogwai ', 'fps       ', 10);\n        expect(consoleMock.warn).toHaveBeenNthCalledWith(2, 'mogwai ', 'fps       ', 10);\n    });\n});\n"
  },
  {
    "path": "src/mogwais/gizmo.js",
    "content": "const defaultConfig = { maxErrors: 10 };\n\nexport default (userConfig) => ({ logger, stop, window }) => {\n    const config = { ...defaultConfig, ...userConfig };\n\n    let realOnError;\n    let realLoggerError;\n\n    const gizmoMogwai = () => {\n        let nbErrors = 0;\n        const incrementNbErrors = () => {\n            nbErrors++;\n            if (nbErrors === config.maxErrors) {\n                stop();\n                if (!logger) return;\n                window.setTimeout(() => {\n                    logger.warn('mogwai ', 'gizmo     ', 'stopped test execution after ', config.maxErrors, 'errors');\n                }, 4);\n            }\n        };\n\n        realOnError = window.onerror;\n        window.onerror = (...args) => {\n            incrementNbErrors();\n            return realOnError ? realOnError(...args) : false;\n        };\n\n        realLoggerError = console.error;\n        console.error = (...args) => {\n            incrementNbErrors();\n            realLoggerError(...args);\n        };\n    };\n\n    gizmoMogwai.cleanUp = () => {\n        window.onerror = realOnError;\n        console.error = realLoggerError.bind(console);\n        return gizmoMogwai;\n    };\n\n    return gizmoMogwai;\n};\n"
  },
  {
    "path": "src/mogwais/gizmo.spec.js",
    "content": "import gizmo from './gizmo';\n\njest.useFakeTimers();\n\ndescribe('gizmo', () => {\n    let config;\n    let stopMock;\n    let consoleErrorSpy;\n    let windowErrorSpy = jest.fn();\n\n    beforeEach(() => {\n        stopMock = jest.fn();\n        consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();\n        window.onerror = windowErrorSpy;\n        config = {\n            logger: console,\n            stop: stopMock,\n            window,\n        };\n    });\n\n    it('should call console.error with right args', () => {\n        const mogwais = gizmo()(config);\n\n        mogwais();\n\n        console.error('first error');\n\n        expect(consoleErrorSpy).toHaveBeenCalledTimes(1);\n        expect(consoleErrorSpy).toHaveBeenCalledWith('first error');\n    });\n\n    it('should call window.error with right args', () => {\n        const mogwais = gizmo()(config);\n\n        mogwais();\n\n        window.onerror('first error', 'https://foo.bar', 10);\n\n        expect(windowErrorSpy).toHaveBeenCalledTimes(1);\n        expect(windowErrorSpy).toHaveBeenCalledWith('first error', 'https://foo.bar', 10);\n    });\n\n    it('should call stop when maxErrors is reached', () => {\n        const mogwais = gizmo({ maxErrors: 2 })(config);\n\n        mogwais();\n\n        console.error('first error');\n        console.error('second', 'error');\n\n        expect(consoleErrorSpy).toHaveBeenCalledTimes(2);\n        expect(consoleErrorSpy).toHaveBeenNthCalledWith(1, 'first error');\n        expect(consoleErrorSpy).toHaveBeenNthCalledWith(2, 'second', 'error');\n\n        expect(stopMock).toHaveBeenCalledTimes(1);\n\n        expect(setTimeout).toHaveBeenCalledTimes(1);\n        expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 4);\n    });\n});\n"
  },
  {
    "path": "src/species/clicker.js",
    "content": "const getDefaultConfig = (randomizer, window) => {\n    const document = window.document;\n    const body = document.body;\n\n    const defaultClickTypes = [\n        'click',\n        'click',\n        'click',\n        'click',\n        'click',\n        'click',\n        'dblclick',\n        'dblclick',\n        'mousedown',\n        'mouseup',\n        'mouseover',\n        'mouseover',\n        'mouseover',\n        'mousemove',\n        'mouseout',\n    ];\n\n    const defaultPositionSelector = () => {\n        return [\n            randomizer.natural({\n                max: Math.max(0, document.documentElement.clientWidth - 1),\n            }),\n            randomizer.natural({\n                max: Math.max(0, document.documentElement.clientHeight - 1),\n            }),\n        ];\n    };\n\n    const defaultShowAction = (x, y) => {\n        const clickSignal = document.createElement('div');\n        clickSignal.style.zIndex = 2000;\n        clickSignal.style.border = '3px solid red';\n        // todo clean chrome/mozilla hack\n        clickSignal.style['border-radius'] = '50%'; // Chrome\n        clickSignal.style.borderRadius = '50%'; // Mozilla\n        clickSignal.style.width = '40px';\n        clickSignal.style.height = '40px';\n        clickSignal.style['box-sizing'] = 'border-box';\n        clickSignal.style.position = 'absolute';\n        clickSignal.style.webkitTransition = 'opacity 1s ease-out';\n        clickSignal.style.mozTransition = 'opacity 1s ease-out';\n        clickSignal.style.transition = 'opacity 1s ease-out';\n        clickSignal.style.left = x - 20 + 'px';\n        clickSignal.style.top = y - 20 + 'px';\n        const element = body.appendChild(clickSignal);\n        setTimeout(() => {\n            body.removeChild(element);\n        }, 1000);\n        setTimeout(() => {\n            element.style.opacity = 0;\n        }, 50);\n    };\n\n    const defaultCanClick = () => {\n        return true;\n    };\n    return {\n        clickTypes: defaultClickTypes,\n        positionSelector: defaultPositionSelector,\n        showAction: defaultShowAction,\n        canClick: defaultCanClick,\n        maxNbTries: 10,\n        log: false,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const document = window.document;\n    const config = {\n        ...getDefaultConfig(randomizer, window),\n        ...userConfig,\n    };\n\n    return () => {\n        let position;\n        let posX;\n        let posY;\n        let targetElement;\n        let nbTries = 0;\n\n        do {\n            position = config.positionSelector();\n            posX = position[0];\n            posY = position[1];\n            targetElement = document.elementFromPoint(posX, posY);\n            nbTries++;\n            if (nbTries > config.maxNbTries) return;\n        } while (!targetElement || !config.canClick(targetElement));\n\n        const evt = document.createEvent('MouseEvents');\n        const clickType = randomizer.pick(config.clickTypes);\n        // todo remove deprecated https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent\n        evt.initMouseEvent(clickType, true, true, window, 0, 0, 0, posX, posY, false, false, false, false, 0, null);\n        targetElement.dispatchEvent(evt);\n\n        if (typeof config.showAction === 'function') {\n            config.showAction(posX, posY, clickType);\n        }\n\n        if (logger && config.log) {\n            logger.log('gremlin', 'clicker   ', clickType, 'at', posX, posY);\n        }\n    };\n};\n"
  },
  {
    "path": "src/species/clicker.spec.js",
    "content": "import clicker from './clicker';\n\njest.useFakeTimers();\n\ndescribe('clicker', () => {\n    const dispatchEventSpy = jest.fn();\n    const initMouseEventSpy = jest.fn();\n    let config;\n    let consoleMock;\n    let chanceMock;\n\n    beforeEach(() => {\n        consoleMock = { log: jest.fn() };\n        chanceMock = {\n            natural: ({ max }) => max,\n            pick: (types) => types[0], // return click types\n        };\n\n        document.body.innerHTML = '<div id=\"myid\">my div</div>';\n\n        // can't be delete in afterEach...\n        if (document.elementFromPoint === undefined) {\n            Object.defineProperty(document, 'elementFromPoint', {\n                get: () => () => ({\n                    ...document.getElementById('myid'),\n                    dispatchEvent: dispatchEventSpy,\n                }),\n            });\n        }\n\n        Object.defineProperty(document.documentElement, 'clientWidth', {\n            value: 11,\n        });\n        Object.defineProperty(document.documentElement, 'clientHeight', {\n            value: 11,\n        });\n        jest.spyOn(document, 'createEvent').mockImplementation(() => ({ initMouseEvent: initMouseEventSpy }));\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    it('should log the cliker', () => {\n        const species = clicker({ log: true })(config);\n\n        species();\n\n        expect(consoleMock.log).toHaveBeenCalledTimes(1);\n        expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'clicker   ', 'click', 'at', 10, 10);\n    });\n\n    it(\"should click on element but don't show element\", () => {\n        const species = clicker({ showAction: false })(config);\n\n        species();\n\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n        expect(document.getElementsByTagName('div')).toHaveLength(1);\n    });\n\n    it(\"should try to click twice on element but can't click at the end\", () => {\n        const canClickSpy = jest.fn();\n        const species = clicker({ canClick: canClickSpy, maxNbTries: 2 })(config);\n\n        species();\n\n        expect(canClickSpy).toHaveBeenCalledTimes(2);\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(0);\n    });\n\n    it('should click on myid element and add new element', () => {\n        const species = clicker()(config);\n\n        species();\n\n        // Click on myid element\n        expect(initMouseEventSpy).toHaveBeenCalledWith(\n            'click',\n            true,\n            true,\n            window,\n            0,\n            0,\n            0,\n            10,\n            10,\n            false,\n            false,\n            false,\n            false,\n            0,\n            null\n        );\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n\n        // Add div element\n        expect(document.getElementsByTagName('div')).toHaveLength(2);\n\n        expect(setTimeout).toHaveBeenCalledTimes(2);\n        expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 1000);\n        expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 50);\n    });\n});\n"
  },
  {
    "path": "src/species/formFiller.js",
    "content": "const getDefaultConfig = (randomizer, window) => {\n    const document = window.document;\n\n    /**\n     * Hacky function to trigger react, angular & vue.js onChange on input\n     */\n    const triggerSimulatedOnChange = (element, newValue, prototype) => {\n        const lastValue = element.value;\n        element.value = newValue;\n\n        const nativeInputValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;\n        nativeInputValueSetter.call(element, newValue);\n        const event = new Event('input', { bubbles: true });\n\n        // React 15\n        event.simulated = true;\n        // React >= 16\n        let tracker = element._valueTracker;\n        if (tracker) {\n            tracker.setValue(lastValue);\n        }\n        element.dispatchEvent(event);\n    };\n\n    const fillTextElement = (element) => {\n        const character = randomizer.character();\n        const newValue = element.value + character;\n        triggerSimulatedOnChange(element, newValue, window.HTMLInputElement.prototype);\n\n        return character;\n    };\n\n    const fillTextAreaElement = (element) => {\n        const character = randomizer.character();\n        const newValue = element.value + character;\n        triggerSimulatedOnChange(element, newValue, window.HTMLTextAreaElement.prototype);\n\n        return character;\n    };\n\n    const fillNumberElement = (element) => {\n        const number = randomizer.character({ pool: '0123456789' });\n        const newValue = element.value + number;\n        triggerSimulatedOnChange(element, newValue, window.HTMLInputElement.prototype);\n\n        return number;\n    };\n\n    const fillSelect = (element) => {\n        const options = element.querySelectorAll('option');\n        if (options.length === 0) return;\n        const randomOption = randomizer.pick(options);\n        options.forEach((option) => {\n            option.selected = option.value === randomOption.value;\n        });\n\n        return randomOption.value;\n    };\n\n    const fillRadio = (element) => {\n        // using mouse events to trigger listeners\n        const evt = document.createEvent('MouseEvents');\n        evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);\n        element.dispatchEvent(evt);\n\n        return element.value;\n    };\n\n    const fillCheckbox = (element) => {\n        // using mouse events to trigger listeners\n        const evt = document.createEvent('MouseEvents');\n        evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);\n        element.dispatchEvent(evt);\n\n        return element.value;\n    };\n\n    const fillEmail = (element) => {\n        const email = randomizer.email();\n        triggerSimulatedOnChange(element, email, window.HTMLInputElement.prototype);\n\n        return email;\n    };\n\n    const defaultMapElements = {\n        textarea: fillTextAreaElement,\n        'input[type=\"text\"]': fillTextElement,\n        'input[type=\"password\"]': fillTextElement,\n        'input[type=\"number\"]': fillNumberElement,\n        select: fillSelect,\n        'input[type=\"radio\"]': fillRadio,\n        'input[type=\"checkbox\"]': fillCheckbox,\n        'input[type=\"email\"]': fillEmail,\n        'input:not([type])': fillTextElement,\n    };\n\n    const defaultShowAction = (element) => {\n        if (typeof element.attributes['data-old-border'] === 'undefined') {\n            element.attributes['data-old-border'] = element.style.border;\n        }\n\n        const oldBorder = element.attributes['data-old-border'];\n        element.style.border = '1px solid red';\n\n        setTimeout(() => {\n            element.style.border = oldBorder;\n        }, 500);\n    };\n\n    const defaultCanFillElement = () => {\n        return true;\n    };\n\n    return {\n        elementMapTypes: defaultMapElements,\n        showAction: defaultShowAction,\n        canFillElement: defaultCanFillElement,\n        maxNbTries: 10,\n        log: false,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const document = window.document;\n\n    const config = { ...getDefaultConfig(randomizer, window), ...userConfig };\n\n    return () => {\n        // Retrieve all selectors\n        const elementTypes = Object.keys(config.elementMapTypes);\n\n        let element;\n        let nbTries = 0;\n\n        do {\n            // Find a random element within all selectors\n            const elements = document.querySelectorAll(elementTypes.join(','));\n            if (elements.length === 0) return;\n            element = randomizer.pick(elements);\n            nbTries++;\n            if (nbTries > config.maxNbTries) return;\n        } while (!element || !config.canFillElement(element));\n\n        // Retrieve element type\n        const elementType = Object.keys(config.elementMapTypes).find((selector) => element.matches(selector));\n\n        const value = config.elementMapTypes[elementType](element);\n\n        if (typeof config.showAction === 'function') {\n            config.showAction(element);\n        }\n\n        if (logger && config.log) {\n            logger.log('gremlin', 'formFiller', 'input', value, 'in', element);\n        }\n    };\n};\n"
  },
  {
    "path": "src/species/formFiller.spec.js",
    "content": "import formFiller from './formFiller';\n\njest.useFakeTimers();\n\ndescribe('formFiller', () => {\n    let consoleMock;\n    let inputText;\n    let chanceMock;\n    let config;\n\n    beforeEach(() => {\n        consoleMock = { log: jest.fn() };\n        chanceMock = {\n            character: () => 1,\n            email: () => 'cofveve@cofveve.com',\n            pick: (types) => types[0], // return click types\n        };\n\n        inputText = document.createElement('input');\n        inputText.setAttribute('type', 'text');\n        inputText.setAttribute('id', 'myid');\n        document.body.appendChild(inputText);\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    afterEach(() => {\n        document.body.innerHTML = '';\n    });\n\n    it('should log the formFiller', () => {\n        const species = formFiller({ log: true })(config);\n\n        species();\n\n        expect(consoleMock.log).toHaveBeenCalledTimes(1);\n        expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'formFiller', 'input', 1, 'in', inputText);\n    });\n\n    it(\"should fill element but don't show element\", () => {\n        const species = formFiller({ showAction: false })(config);\n\n        species();\n\n        expect(document.getElementById('myid')).toBe(inputText);\n        expect(inputText.value).toBe('1');\n    });\n\n    it(\"should try to fill twice on element but can't fill at the end\", () => {\n        const canFillElementSpy = jest.fn();\n        const species = formFiller({ canFillElement: canFillElementSpy, maxNbTries: 2 })(config);\n\n        species();\n\n        expect(canFillElementSpy).toHaveBeenCalledTimes(2);\n        expect(inputText.value).toBe('');\n    });\n\n    it('should fill element and add new element', () => {\n        const species = formFiller()(config);\n\n        species();\n\n        expect(inputText.value).toBe('1');\n\n        expect(setTimeout).toHaveBeenCalledTimes(1);\n        expect(setTimeout).toHaveBeenCalledWith(expect.any(Function), 500);\n    });\n});\n"
  },
  {
    "path": "src/species/scroller.js",
    "content": "const getDefaultConfig = (randomizer, window) => {\n    const document = window.document;\n    const documentElement = document.documentElement;\n    const body = document.body;\n\n    const defaultPositionSelector = () => {\n        const documentWidth = Math.max(\n            body.scrollWidth,\n            body.offsetWidth,\n            documentElement.scrollWidth,\n            documentElement.offsetWidth,\n            documentElement.clientWidth\n        );\n        const documentHeight = Math.max(\n            body.scrollHeight,\n            body.offsetHeight,\n            documentElement.scrollHeight,\n            documentElement.offsetHeight,\n            documentElement.clientHeight\n        );\n\n        return [\n            randomizer.natural({\n                max: documentWidth - documentElement.clientWidth,\n            }),\n            randomizer.natural({\n                max: documentHeight - documentElement.clientHeight,\n            }),\n        ];\n    };\n\n    const defaultShowAction = (scrollX, scrollY) => {\n        const scrollSignal = document.createElement('div');\n        scrollSignal.style.zIndex = 2000;\n        scrollSignal.style.border = '3px solid red';\n        scrollSignal.style.width = documentElement.clientWidth - 25 + 'px';\n        scrollSignal.style.height = documentElement.clientHeight - 25 + 'px';\n        scrollSignal.style.position = 'absolute';\n        scrollSignal.style.webkitTransition = 'opacity 1s ease-out';\n        scrollSignal.style.mozTransition = 'opacity 1s ease-out';\n        scrollSignal.style.transition = 'opacity 1s ease-out';\n        scrollSignal.style.left = scrollX + 10 + 'px';\n        scrollSignal.style.top = scrollY + 10 + 'px';\n        scrollSignal.style['pointer-events'] = 'none';\n\n        const element = body.appendChild(scrollSignal);\n        setTimeout(() => {\n            body.removeChild(element);\n        }, 1000);\n        setTimeout(() => {\n            element.style.opacity = 0;\n        }, 50);\n    };\n\n    return {\n        positionSelector: defaultPositionSelector,\n        showAction: defaultShowAction,\n        log: false,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const config = { ...getDefaultConfig(randomizer, window), ...userConfig };\n    return () => {\n        const position = config.positionSelector();\n        const scrollX = position[0];\n        const scrollY = position[1];\n\n        window.scrollTo(scrollX, scrollY);\n\n        if (typeof config.showAction === 'function') {\n            config.showAction(scrollX, scrollY);\n        }\n\n        if (logger && config.log) {\n            logger.log('gremlin', 'scroller  ', 'scroll to', scrollX, scrollY);\n        }\n    };\n};\n"
  },
  {
    "path": "src/species/scroller.spec.js",
    "content": "import scroller from './scroller';\n\njest.useFakeTimers();\n\ndescribe('scroller', () => {\n    let consoleMock;\n    let chanceMock;\n    let config;\n\n    const scrollToSpy = jest.fn();\n\n    beforeEach(() => {\n        consoleMock = { log: jest.fn() };\n        chanceMock = {\n            natural: ({ max }) => max,\n        };\n\n        Object.defineProperty(window, 'scrollTo', { value: scrollToSpy, writable: true });\n\n        const documentElementProps = {\n            clientWidth: 10,\n            clientHeight: 10,\n            scrollWidth: 15,\n            scrollHeight: 15,\n        };\n        Object.keys(documentElementProps).forEach((key) => {\n            Object.defineProperty(document.documentElement, key, {\n                value: documentElementProps[key],\n            });\n        });\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    it('should log the scroller', () => {\n        const species = scroller({ log: true })(config);\n\n        species();\n\n        expect(consoleMock.log).toHaveBeenCalledTimes(1);\n        expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'scroller  ', 'scroll to', 5, 5);\n    });\n\n    it(\"should scroll but don't show element\", () => {\n        const species = scroller({ showAction: false })(config);\n\n        species();\n\n        expect(scrollToSpy).toHaveBeenCalledTimes(1);\n        expect(scrollToSpy).toHaveBeenCalledWith(5, 5);\n        expect(document.getElementsByTagName('div')).toHaveLength(1);\n    });\n\n    it('should scroll and add new element', () => {\n        const species = scroller()(config);\n\n        species();\n\n        expect(scrollToSpy).toHaveBeenCalledTimes(1);\n        expect(scrollToSpy).toHaveBeenCalledWith(5, 5);\n        expect(document.getElementsByTagName('div')).toHaveLength(2);\n\n        expect(setTimeout).toHaveBeenCalledTimes(2);\n        expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 1000);\n        expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 50);\n    });\n});\n"
  },
  {
    "path": "src/species/toucher.js",
    "content": "const getDefaultConfig = (randomizer, window) => {\n    const document = window.document;\n    const body = document.body;\n\n    const defaultTouchTypes = [\n        'tap',\n        'tap',\n        'tap',\n        'doubletap',\n        'gesture',\n        'gesture',\n        'gesture',\n        'multitouch',\n        'multitouch',\n    ];\n\n    const defaultPositionSelector = () => {\n        return [\n            randomizer.natural({\n                max: Math.max(0, document.documentElement.clientWidth - 1),\n            }),\n            randomizer.natural({\n                max: Math.max(0, document.documentElement.clientHeight - 1),\n            }),\n        ];\n    };\n\n    const defaultShowAction = (touches) => {\n        const fragment = document.createDocumentFragment();\n        touches.forEach((touch) => {\n            const touchSignal = document.createElement('div');\n            touchSignal.style.zIndex = 2000;\n            touchSignal.style.background = 'red';\n            touchSignal.style['border-radius'] = '50%'; // Chrome\n            touchSignal.style.borderRadius = '50%'; // Mozilla\n            touchSignal.style.width = '20px';\n            touchSignal.style.height = '20px';\n            touchSignal.style.position = 'absolute';\n            touchSignal.style.webkitTransition = 'opacity .5s ease-out';\n            touchSignal.style.mozTransition = 'opacity .5s ease-out';\n            touchSignal.style.transition = 'opacity .5s ease-out';\n            touchSignal.style.left = touch.x - 10 + 'px';\n            touchSignal.style.top = touch.y - 10 + 'px';\n\n            const element = fragment.appendChild(touchSignal);\n            setTimeout(() => {\n                body.removeChild(element);\n            }, 500);\n            setTimeout(() => {\n                element.style.opacity = 0;\n            }, 50);\n        });\n        document.body.appendChild(fragment);\n    };\n\n    const defaultCanTouch = () => {\n        return true;\n    };\n\n    return {\n        touchTypes: defaultTouchTypes,\n        positionSelector: defaultPositionSelector,\n        showAction: defaultShowAction,\n        canTouch: defaultCanTouch,\n        maxNbTries: 10,\n        maxTouches: 2,\n        log: false,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const document = window.document;\n    const config = { ...getDefaultConfig(randomizer, window), ...userConfig };\n\n    const getTouches = (center, points, radius, degrees) => {\n        const cx = center[0];\n        const cy = center[1];\n        const touches = [];\n\n        // just one touch, at the center\n        if (points === 1) {\n            return [{ x: cx, y: cy }];\n        }\n\n        radius = radius || 100;\n        degrees = degrees !== null ? (degrees * Math.PI) / 180 : 0;\n        const slice = (2 * Math.PI) / points;\n\n        for (let i = 0; i < points; i++) {\n            let angle = slice * i + degrees;\n            touches.push({\n                x: cx + radius * Math.cos(angle),\n                y: cy + radius * Math.sin(angle),\n            });\n        }\n        return touches;\n    };\n\n    const triggerTouch = (touches, element, type) => {\n        const touchlist = [];\n        const event = document.createEvent('Event');\n\n        event.initEvent('touch' + type, true, true);\n\n        touches.forEach((touch, i) => {\n            const x = Math.round(touch.x);\n            const y = Math.round(touch.y);\n            touchlist.push({\n                pageX: x,\n                pageY: y,\n                clientX: x,\n                clientY: y,\n                screenX: x,\n                screenY: y,\n                target: element,\n                identifier: i,\n            });\n        });\n\n        event.touches = type === 'end' ? [] : touchlist;\n        event.targetTouches = type === 'end' ? [] : touchlist;\n        event.changedTouches = touchlist;\n\n        element.dispatchEvent(event);\n        if (typeof config.showAction === 'function') {\n            config.showAction(touches);\n        }\n    };\n\n    const triggerGesture = (element, startPos, startTouches, gesture, done) => {\n        const interval = 10;\n        const loops = Math.ceil(gesture.duration / interval);\n        let loop = 1;\n\n        const gestureLoop = () => {\n            // calculate the radius\n            let radius = gesture.radius;\n            if (gesture.scale !== 1) {\n                radius = gesture.radius - gesture.radius * (1 - gesture.scale) * ((1 / loops) * loop);\n            }\n\n            // calculate new position/rotation\n            const posX = startPos[0] + (gesture.distanceX / loops) * loop;\n            const posY = startPos[1] + (gesture.distanceY / loops) * loop;\n            const rotation = typeof gesture.rotation === 'number' ? (gesture.rotation / loops) * loop : null;\n            const touches = getTouches([posX, posY], startTouches.length, radius, rotation);\n            const isFirst = loop === 1;\n            const isLast = loop === loops;\n\n            if (isFirst) {\n                triggerTouch(touches, element, 'start');\n            } else if (isLast) {\n                triggerTouch(touches, element, 'end');\n                return done(touches);\n            } else {\n                triggerTouch(touches, element, 'move');\n            }\n\n            setTimeout(gestureLoop, interval);\n            loop++;\n        };\n        gestureLoop();\n    };\n\n    const touchTypes = {\n        // tap, like a click event, only 1 touch\n        // could also be a slow tap, that could turn out to be a hold\n        tap(position, element, log) {\n            const touches = getTouches(position, 1);\n            const gesture = {\n                duration: randomizer.integer({ min: 20, max: 700 }),\n            };\n\n            triggerTouch(touches, element, 'start');\n\n            setTimeout(() => {\n                triggerTouch(touches, element, 'end');\n\n                log(touches, gesture);\n            }, gesture.duration);\n        },\n\n        // doubletap, like a dblclick event, only 1 touch\n        // could also be a slow doubletap, that could turn out to be a hold\n        doubletap(position, element, log) {\n            touchTypes.tap(position, element, () => {\n                setTimeout(() => {\n                    touchTypes.tap(position, element, log);\n                }, 30);\n            });\n        },\n\n        // single touch gesture, could be a drag and swipe, with 1 points\n        gesture(position, element, log) {\n            const gesture = {\n                distanceX: randomizer.integer({ min: -100, max: 200 }),\n                distanceY: randomizer.integer({ min: -100, max: 200 }),\n                duration: randomizer.integer({ min: 20, max: 500 }),\n            };\n            const touches = getTouches(position, 1, gesture.radius);\n\n            triggerGesture(element, position, touches, gesture, (touches) => {\n                log(touches, gesture);\n            });\n        },\n\n        // multitouch gesture, could be a drag, swipe, pinch and rotate, with 2 or more points\n        multitouch(position, element, log) {\n            const points = randomizer.integer({\n                min: 2,\n                max: config.maxTouches,\n            });\n            const gesture = {\n                scale: randomizer.floating({ min: 0, max: 2 }),\n                rotation: randomizer.natural({ min: 0, max: 100 }),\n                radius: randomizer.integer({ min: 50, max: 200 }),\n                distanceX: randomizer.integer({ min: -20, max: 20 }),\n                distanceY: randomizer.integer({ min: -20, max: 20 }),\n                duration: randomizer.integer({ min: 100, max: 1500 }),\n            };\n            const touches = getTouches(position, points, gesture.radius);\n\n            triggerGesture(element, position, touches, gesture, (touches) => {\n                log(touches, gesture);\n            });\n        },\n    };\n\n    return () => {\n        let position;\n        let posX;\n        let posY;\n        let targetElement;\n        let nbTries = 0;\n\n        do {\n            position = config.positionSelector();\n            posX = position[0];\n            posY = position[1];\n            targetElement = document.elementFromPoint(posX, posY);\n            nbTries++;\n            if (nbTries > config.maxNbTries) return;\n        } while (!targetElement || !config.canTouch(targetElement));\n\n        const touchType = randomizer.pick(config.touchTypes);\n        const log = (touches, details) => {\n            if (typeof config.showAction === 'function') {\n                config.showAction(touches);\n            }\n            if (logger && config.log) {\n                logger.log('gremlin', 'toucher', touchType, 'at', posX, posY, details);\n            }\n        };\n        touchTypes[touchType](position, targetElement, log);\n    };\n};\n"
  },
  {
    "path": "src/species/toucher.spec.js",
    "content": "import toucher from './toucher';\n\ndescribe('toucher', () => {\n    const dispatchEventSpy = jest.fn();\n    const initEventSpy = jest.fn();\n    let config;\n    let inputText;\n    let chanceMock;\n    let consoleMock;\n\n    beforeEach(() => {\n        chanceMock = {\n            natural: ({ max }) => max,\n            floating: ({ max }) => max,\n            integer: ({ max }) => max,\n            pick: (types) => types[0],\n        };\n        consoleMock = { log: jest.fn() };\n\n        inputText = document.createElement('input');\n        inputText.setAttribute('type', 'text');\n        inputText.setAttribute('id', 'myid');\n        document.body.appendChild(inputText);\n\n        // can't be delete in afterEach...\n        if (document.elementFromPoint === undefined) {\n            Object.defineProperty(document, 'elementFromPoint', {\n                get: () => () => ({\n                    ...document.getElementById('myid'),\n                    dispatchEvent: dispatchEventSpy,\n                }),\n            });\n        }\n\n        Object.defineProperty(document.documentElement, 'clientWidth', {\n            value: 11,\n        });\n        Object.defineProperty(document.documentElement, 'clientHeight', {\n            value: 11,\n        });\n        jest.spyOn(document, 'createEvent').mockImplementation(() => ({ initEvent: initEventSpy }));\n\n        jest.useFakeTimers();\n\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    afterEach(() => {\n        document.body.innerHTML = '';\n    });\n\n    it('should log the toucher', () => {\n        const species = toucher({ log: true })(config);\n\n        species();\n        jest.runAllTimers();\n        expect(consoleMock.log).toHaveBeenCalledTimes(1);\n        expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'toucher', 'tap', 'at', 10, 10, { duration: 700 });\n    });\n\n    it(\"should touch the element but don't show element\", () => {\n        const species = toucher({ showAction: false })(config);\n\n        species();\n\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n        expect(document.getElementsByTagName('div')).toHaveLength(0);\n    });\n\n    it('should touch on myid element and add new element', () => {\n        const species = toucher()(config);\n\n        species();\n\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n\n        expect(document.getElementsByTagName('div')).toHaveLength(1);\n\n        expect(setTimeout).toHaveBeenCalledTimes(3);\n        expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 500);\n        expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 50);\n        expect(setTimeout).toHaveBeenNthCalledWith(3, expect.any(Function), 700);\n    });\n});\n"
  },
  {
    "path": "src/species/typer.js",
    "content": "const getDefaultConfig = (randomizer, window) => {\n    const document = window.document;\n    const body = document.body;\n\n    const defaultEventTypes = ['keypress', 'keyup', 'keydown'];\n\n    const defaultKeyGenerator = () => {\n        return randomizer.natural({ min: 3, max: 254 });\n    };\n\n    const defaultTargetElement = (x, y) => {\n        return document.elementFromPoint(x, y);\n    };\n\n    const defaultShowAction = (targetElement, x, y, key) => {\n        const typeSignal = document.createElement('div');\n        typeSignal.style.zIndex = 2000;\n        typeSignal.style.border = '3px solid orange';\n        typeSignal.style['border-radius'] = '50%'; // Chrome\n        typeSignal.style.borderRadius = '50%'; // Mozilla\n        typeSignal.style.width = '40px';\n        typeSignal.style.height = '40px';\n        typeSignal.style['box-sizing'] = 'border-box';\n        typeSignal.style.position = 'absolute';\n        typeSignal.style.webkitTransition = 'opacity 1s ease-out';\n        typeSignal.style.mozTransition = 'opacity 1s ease-out';\n        typeSignal.style.transition = 'opacity 1s ease-out';\n        typeSignal.style.left = x + 'px';\n        typeSignal.style.top = y + 'px';\n        typeSignal.style.textAlign = 'center';\n        typeSignal.style.paddingTop = '7px';\n        typeSignal.innerHTML = String.fromCharCode(key);\n\n        const element = body.appendChild(typeSignal);\n        setTimeout(() => {\n            body.removeChild(element);\n        }, 1000);\n        setTimeout(() => {\n            element.style.opacity = 0;\n        }, 50);\n    };\n\n    return {\n        eventTypes: defaultEventTypes,\n        showAction: defaultShowAction,\n        keyGenerator: defaultKeyGenerator,\n        targetElement: defaultTargetElement,\n        log: false,\n    };\n};\n\nexport default (userConfig) => ({ logger, randomizer, window }) => {\n    const document = window.document;\n    const documentElement = document.documentElement;\n    const config = { ...getDefaultConfig(randomizer, window), ...userConfig };\n\n    return () => {\n        const keyboardEvent = document.createEventObject\n            ? document.createEventObject()\n            : document.createEvent('Events');\n        const eventType = randomizer.pick(config.eventTypes);\n        const key = config.keyGenerator();\n        const posX = randomizer.natural({\n            max: Math.max(0, documentElement.clientWidth - 1),\n        });\n        const posY = randomizer.natural({\n            max: Math.max(0, documentElement.clientHeight - 1),\n        });\n        const targetElement = config.targetElement(posX, posY);\n\n        if (keyboardEvent.initEvent) {\n            keyboardEvent.initEvent(eventType, true, true);\n        }\n\n        keyboardEvent.keyCode = key;\n        keyboardEvent.which = key;\n        keyboardEvent.keyCodeVal = key;\n\n        if (targetElement.dispatchEvent) {\n            targetElement.dispatchEvent(keyboardEvent);\n        } else {\n            targetElement.fireEvent('on' + eventType, keyboardEvent);\n        }\n\n        if (typeof config.showAction === 'function') {\n            config.showAction(targetElement, posX, posY, key);\n        }\n\n        if (config.log && logger) {\n            logger.log('gremlin', 'typer type', String.fromCharCode(key), 'at', posX, posY);\n        }\n    };\n};\n"
  },
  {
    "path": "src/species/typer.spec.js",
    "content": "import typer from './typer';\n\njest.useFakeTimers();\n\ndescribe('typer', () => {\n    const dispatchEventSpy = jest.fn();\n    const initMouseEventSpy = jest.fn();\n    let consoleMock;\n    let inputText;\n    let chanceMock;\n    let config;\n    beforeEach(() => {\n        consoleMock = { log: jest.fn() };\n        chanceMock = {\n            natural: ({ min, max }) => (min ? 65 : max), // 65 = a\n            pick: (types) => types[0],\n        };\n\n        inputText = document.createElement('input');\n        inputText.setAttribute('type', 'text');\n        inputText.setAttribute('id', 'myid');\n        document.body.appendChild(inputText);\n\n        // can't be delete in afterEach...\n        if (document.elementFromPoint === undefined) {\n            Object.defineProperty(document, 'elementFromPoint', {\n                get: () => () => ({\n                    ...document.getElementById('myid'),\n                    dispatchEvent: dispatchEventSpy,\n                }),\n            });\n        }\n\n        Object.defineProperty(document.documentElement, 'clientWidth', {\n            value: 11,\n        });\n        Object.defineProperty(document.documentElement, 'clientHeight', {\n            value: 11,\n        });\n        jest.spyOn(document, 'createEvent').mockImplementation(() => ({ initMouseEvent: initMouseEventSpy }));\n\n        config = {\n            logger: consoleMock,\n            randomizer: chanceMock,\n            window,\n        };\n    });\n\n    afterEach(() => {\n        document.body.innerHTML = '';\n    });\n\n    it('should log the typer', () => {\n        const species = typer({ log: true })(config);\n\n        species();\n\n        expect(consoleMock.log).toHaveBeenCalledTimes(1);\n        expect(consoleMock.log).toHaveBeenCalledWith('gremlin', 'typer type', 'A', 'at', 10, 10);\n    });\n\n    it(\"should type on element but don't show element\", () => {\n        const species = typer({ showAction: false })(config);\n\n        species();\n\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n        expect(dispatchEventSpy).toHaveBeenCalledWith({\n            initMouseEvent: initMouseEventSpy,\n            keyCode: 65,\n            which: 65,\n            keyCodeVal: 65,\n        });\n        expect(document.getElementsByTagName('div')).toHaveLength(0);\n    });\n\n    it('should type on myid element and add new element', () => {\n        const species = typer()(config);\n\n        species();\n\n        expect(dispatchEventSpy).toHaveBeenCalledTimes(1);\n        expect(dispatchEventSpy).toHaveBeenCalledWith({\n            initMouseEvent: initMouseEventSpy,\n            keyCode: 65,\n            which: 65,\n            keyCodeVal: 65,\n        });\n\n        expect(document.getElementsByTagName('div')).toHaveLength(1);\n\n        expect(setTimeout).toHaveBeenCalledTimes(2);\n        expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 1000);\n        expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 50);\n    });\n});\n"
  },
  {
    "path": "src/strategies/allTogether.js",
    "content": "import executeInSeries from '../utils/executeInSeries';\nimport wait from '../utils/wait';\n\nexport default (userConfig) => () => {\n    const defaultConfig = {\n        delay: 10, // delay in milliseconds between each wave\n        nb: 100, // number of waves to execute (can be overridden in params)\n    };\n\n    const config = { ...defaultConfig, ...userConfig };\n\n    let stopped = false;\n\n    const allTogetherStrategy = async (gremlins) => {\n        const { nb, delay } = config;\n\n        for (let i = 0; i < nb; i++) {\n            await wait(delay);\n            if (stopped) {\n                return Promise.resolve();\n            }\n            await executeInSeries(gremlins, []);\n        }\n        return Promise.resolve();\n    };\n\n    allTogetherStrategy.stop = () => {\n        stopped = true;\n    };\n\n    return allTogetherStrategy;\n};\n"
  },
  {
    "path": "src/strategies/allTogether.spec.js",
    "content": "import allTogether from './allTogether';\n\nimport * as executeInSeries from '../utils/executeInSeries';\nimport * as wait from '../utils/wait';\n\njest.useFakeTimers();\n\ndescribe('allTogether', () => {\n    it('should contains stop function', async () => {\n        const strategies = allTogether({ nb: 2 })();\n        expect(typeof strategies.stop === 'function').toBe(true);\n    });\n\n    it('should call executeInSeries with all gremlins', async () => {\n        const executeInSeriesSpy = jest.spyOn(executeInSeries, 'default').mockImplementation();\n        const waitSpy = jest.spyOn(wait, 'default').mockImplementation();\n\n        const gremlins = [{ name: 'firstGremlins' }, { name: 'secondGremlins' }];\n        const strategies = allTogether({ nb: 2 })();\n\n        await expect(strategies(gremlins)).resolves.toBe();\n\n        expect(waitSpy).toHaveBeenCalledTimes(2);\n        expect(executeInSeriesSpy).toHaveBeenCalledTimes(2);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(1, gremlins, []);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(2, gremlins, []);\n    });\n\n    it(\"should don't call executeInSeries twice when strategies is stop\", async () => {\n        const executeInSeriesSpy = jest.spyOn(executeInSeries, 'default').mockImplementation();\n        const waitSpy = jest.spyOn(wait, 'default').mockImplementation();\n\n        const gremlins = [{ name: 'firstGremlins' }];\n        const strategies = allTogether({ nb: 2 })();\n\n        strategies.stop();\n        await expect(strategies(gremlins)).resolves.toBe();\n\n        expect(waitSpy).toHaveBeenCalledTimes(1);\n        expect(executeInSeriesSpy).toHaveBeenCalledTimes(0);\n    });\n});\n"
  },
  {
    "path": "src/strategies/bySpecies.js",
    "content": "import executeInSeries from '../utils/executeInSeries';\nimport wait from '../utils/wait';\n\nexport default (userConfig) => () => {\n    const defaultConfig = {\n        delay: 10, // delay in milliseconds between each wave\n        nb: 100, // number of waves to execute (can be overridden in params)\n    };\n\n    const config = { ...defaultConfig, ...userConfig };\n\n    let stopped = false;\n\n    const bySpeciesStrategy = async (newGremlins) => {\n        const { nb, delay } = config;\n\n        const gremlins = [...newGremlins]; // clone the array to avoid modifying the original\n\n        for (let gremlinIndex in gremlins) {\n            const gremlin = gremlins[gremlinIndex];\n            for (let i = 0; i < nb; i++) {\n                await wait(delay);\n                if (stopped) {\n                    return Promise.resolve();\n                }\n                await executeInSeries([gremlin], []);\n            }\n        }\n        return Promise.resolve();\n    };\n\n    bySpeciesStrategy.stop = () => {\n        stopped = true;\n    };\n\n    return bySpeciesStrategy;\n};\n"
  },
  {
    "path": "src/strategies/bySpecies.spec.js",
    "content": "import bySpecies from './bySpecies';\n\nimport * as executeInSeries from '../utils/executeInSeries';\nimport * as wait from '../utils/wait';\n\njest.useFakeTimers();\n\ndescribe('bySpecies', () => {\n    beforeEach(() => {});\n\n    it('should contains stop function', async () => {\n        const strategies = bySpecies({ nb: 2 })();\n        expect(typeof strategies.stop === 'function').toBe(true);\n    });\n\n    it('should call executeInSeries by species', async () => {\n        const executeInSeriesSpy = jest.spyOn(executeInSeries, 'default').mockImplementation();\n        const waitSpy = jest.spyOn(wait, 'default').mockImplementation();\n\n        const gremlins = [{ name: 'firstGremlins' }, { name: 'secondGremlins' }];\n        const strategies = bySpecies({ nb: 2 })();\n\n        await expect(strategies(gremlins)).resolves.toBe();\n\n        expect(waitSpy).toHaveBeenCalledTimes(4);\n        expect(executeInSeriesSpy).toHaveBeenCalledTimes(4);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(1, [{ name: 'firstGremlins' }], []);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(2, [{ name: 'firstGremlins' }], []);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(3, [{ name: 'secondGremlins' }], []);\n        expect(executeInSeriesSpy).toHaveBeenNthCalledWith(4, [{ name: 'secondGremlins' }], []);\n    });\n});\n"
  },
  {
    "path": "src/strategies/distribution.js",
    "content": "import executeInSeries from '../utils/executeInSeries';\nimport wait from '../utils/wait';\n\nexport default (userConfig) => (randomizer) => {\n    const defaultConfig = {\n        distribution: [], // percentage of each gremlin species ; the sum of all values should equal to 1\n        delay: 10,\n        nb: 1000,\n    };\n\n    const config = { ...defaultConfig, ...userConfig };\n\n    let stopped = false;\n\n    const distributionStrategy = async (newGremlins) => {\n        const { nb, delay } = config;\n\n        const gremlins = [...newGremlins]; // clone the array to avoid modifying the original\n        const distribution = config.distribution.length === 0 ? getUniformDistribution(gremlins) : config.distribution;\n\n        if (nb === 0) return Promise.resolve();\n\n        for (let i = 0; i < nb; i++) {\n            const gremlin = pickGremlin(gremlins, distribution);\n            await wait(delay);\n            if (stopped) {\n                return Promise.resolve();\n            }\n            await executeInSeries([gremlin], []);\n        }\n        return Promise.resolve();\n    };\n\n    const getUniformDistribution = (newGremlins) => {\n        const len = newGremlins.length;\n        if (len === 0) return [];\n        const distribution = [];\n        const value = 1 / len;\n        for (let i = 0; i < len; i++) {\n            distribution.push(value);\n        }\n        return distribution;\n    };\n\n    const pickGremlin = (newGremlins, distribution) => {\n        let chance = 0;\n        const random = randomizer.floating({ min: 0, max: 1 });\n        for (let i = 0, count = newGremlins.length; i < count; i++) {\n            chance += distribution[i];\n            if (random <= chance) return newGremlins[i];\n        }\n        // no gremlin - probably error in the distribution\n        return () => {};\n    };\n\n    distributionStrategy.stop = () => {\n        stopped = true;\n    };\n\n    return distributionStrategy;\n};\n"
  },
  {
    "path": "src/strategies/distribution.spec.js",
    "content": "import distribution from './distribution';\n\ndescribe('distribution', () => {\n    beforeEach(() => {});\n\n    it('should contains stop function', async () => {\n        const strategies = distribution({ nb: 2 })();\n        expect(typeof strategies.stop === 'function').toBe(true);\n    });\n});\n"
  },
  {
    "path": "src/utils/executeInSeries.js",
    "content": "/**\n * Execute a list of functions one after the other.\n *\n * Functions can be asynchronous or asynchronous, they will always be\n * executed in the order of the list.\n *\n * @param {Function[]} callbacks - The functions to execute\n * @param {Array} args - The arguments passed to each function\n */\nexport default (callables, args) =>\n    callables.reduce((promise, cb) => promise.then(() => cb(...args)), Promise.resolve());\n"
  },
  {
    "path": "src/utils/executeInSeries.spec.js",
    "content": "import executeInSeries from './executeInSeries';\n\ndescribe('executeInSeries', () => {\n    it('should call all callables with correct arguments', async () => {\n        const promise = jest.fn(() => new Promise((resolve) => resolve()));\n        const callable = jest.fn(() => {});\n        const callables = [promise, callable];\n        const args = [1, 2];\n\n        await executeInSeries(callables, args);\n\n        expect(promise).toHaveBeenCalledTimes(1);\n        expect(promise).toHaveBeenLastCalledWith(...args);\n\n        expect(callable).toHaveBeenCalledTimes(1);\n        expect(callable).toHaveBeenLastCalledWith(...args);\n    });\n\n    it('should throw an error and stop executing if an error occur', async () => {\n        const promise = jest.fn(() => new Promise((resolve) => resolve()));\n        const rejectPromise = jest.fn(() => new Promise((_, reject) => reject('test reject')));\n        const callables = [promise, rejectPromise, promise];\n        const args = [1, 2];\n\n        await expect(executeInSeries(callables, args)).rejects.toEqual('test reject');\n\n        expect(promise).toHaveBeenCalledTimes(1);\n        expect(promise).toHaveBeenLastCalledWith(...args);\n\n        expect(rejectPromise).toHaveBeenCalledTimes(1);\n        expect(rejectPromise).toHaveBeenLastCalledWith(...args);\n    });\n});\n"
  },
  {
    "path": "src/utils/wait.js",
    "content": "export default (time) => new Promise((resolve) => setTimeout(resolve, time));\n"
  },
  {
    "path": "src/utils/wait.spec.js",
    "content": "import wait from './wait';\n\njest.useFakeTimers();\n\ndescribe('wait', () => {\n    it('should call setTimeout and wait x ms', () => {\n        wait(1000);\n\n        expect(setTimeout).toHaveBeenCalledTimes(1);\n        expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), 1000);\n    });\n});\n"
  }
]