{"id":24505726,"url":"https://github.com/ioncakephper/yaml2test","last_synced_at":"2026-02-06T13:02:22.581Z","repository":{"id":57403018,"uuid":"452812300","full_name":"ioncakephper/yaml2test","owner":"ioncakephper","description":"Create jest-compatible tests from YAML notation.","archived":false,"fork":false,"pushed_at":"2024-12-07T23:55:10.000Z","size":1040,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T07:07:24.605Z","etag":null,"topics":["generate","generate-code","jest","test","testing-tool","tests","yaml","yaml-files"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ioncakephper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-27T19:14:09.000Z","updated_at":"2022-01-28T00:00:14.000Z","dependencies_parsed_at":"2025-01-10T22:39:59.866Z","dependency_job_id":"c41d89f4-58b3-42bb-8fa8-a4bc701acfa3","html_url":"https://github.com/ioncakephper/yaml2test","commit_stats":{"total_commits":37,"total_committers":1,"mean_commits":37.0,"dds":0.0,"last_synced_commit":"2e00233290bb079ba9904807949586cb5fd70a65"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyaml2test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyaml2test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyaml2test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyaml2test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ioncakephper","download_url":"https://codeload.github.com/ioncakephper/yaml2test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837280,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generate","generate-code","jest","test","testing-tool","tests","yaml","yaml-files"],"created_at":"2025-01-21T23:31:24.306Z","updated_at":"2026-02-06T13:02:17.502Z","avatar_url":"https://github.com/ioncakephper.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yaml2test\n\nCreate jest-compatible tests from YAML notation.\n\n[![DeepScan grade](https://deepscan.io/api/teams/15501/projects/20018/branches/531871/badge/grade.svg)](https://deepscan.io/dashboard#view=project\u0026tid=15501\u0026pid=20018\u0026bid=531871)\n\n## Synopsis\n\n```shell-session\n$ yaml2jest -h\n$ yaml2jest help\n\n$ yaml2jest -V\n$ yaml2jest [build] \u003cbasename\u003e[.yaml]\n$ yaml2jest [build] \u003cbasename\u003e[.yaml] -o \u003ctestbasename\u003e[.test[s]][.[jt]s]\n$ yaml2jest [build] \u003cbasename\u003e[.yaml] -c \u003cconfigbasename\u003e[.json]\n$ yaml2jest [build] \u003cbasename\u003e[.yaml] -o \u003ctestbasename\u003e[.test[s]][.[jt]s] -c \u003cconfigbasename\u003e[.json]\n\n$ yamljest init [\u003cconfigbasename\u003e[.json]]\n```\n\n## Install\n\nUse `npm` and install with `-g` switch to have the `yaml2jest` CLI.\n\n```shell-session\n$ npm i -g yaml2test\n```\n\n## Usage\n\nCreate `app-tests.yaml` as follows:\n\n```yaml\n- my application:\n  - can:\n    - create files and folders\n    - read data from .csv files\n  - should:\n    - work as cli\n    - work as an importable package\n- tests for my application:\n  - should be:\n    - easy to read\n    - error free\n```\n\n### CLI\n\nGet help:\n\n```shell-session\n$ yaml2jest -h\n```\n\n```txt\nUsage: yaml2jest [options] [command]\n\nCreate tests from YAML notation\n\nOptions:\n  -V, --version               output the version number\n  -h, --help                  display help for command\n\nCommands:\n  build [options] \u003cyamlfile\u003e  build tests in a test file (default command)\n  init [configname]           create settings file\n  help [command]              display help for command\n\n```\n\nGet help of `build` -- `yaml2jest`'s defauld sub-command:\n\n```shell-session\n$ yaml2jest help build\n```\n\n```txt\nUsage: yaml2jest build [options] \u003cyamlfile\u003e\n\nbuild tests in a test file (default command)\n\nOptions:\n  -o, --output \u003ctestfile\u003e  fullpath to test file to create (default: \u003cyamlfile-basename\u003e.test.js)\n  -c, --config \u003cfilename\u003e  configuration filename (default: \"yaml2jest.json\")\n  -h, --help               display help for command\n```\n\n**Example 1**: Create test file from `.yaml` file:\n\n```shell-session\n$ yaml2jest app-tests\n```\n\n\u003e use `app-tests.yaml` file as source and generate `app-tests.test.js` file, which is a `jest` compatible test file.\n\nGenerated `app-tests.test.js` will look as follows:\n\n```js\ndescribe(\"my application\", () =\u003e {\n    describe(\"can\", () =\u003e {\n        it.todo(\"create files and folders\");\n        it.todo(\"read data from .csv files\");\n    });\n    describe(\"should\", () =\u003e {\n        it.todo(\"work as cli\");\n        it.todo(\"work as an importable package\");\n    });\n});\ndescribe(\"tests for my application\", () =\u003e {\n    describe(\"should be\", () =\u003e {\n        it.todo(\"easy to read\");\n        it.todo(\"error free\");\n    });\n});\n```\n\n**Example 2**: Specify an output file (path and name of test file to generate)\n\n```shell-session\n$ yaml2jest app-tests -o my-app\n```\n\n\u003e use `app-tests.yaml` file as source and generate the output file `my-app.app.test.js`\n\n### Code\n\nUse the `app-tests.yaml` as described for CLI.\n\n```js\nconst {createSuite} = 'yaml2test`;\nconst yamljs = require('yamljs');\n\nlet items = yamljs.load('app-tests.yaml');\nlet code = createSuite(items);\nconsole.log(code);\n```\n\n## YAML file examples\n\n### One of more test cases\n\n```yaml\n- test case 1\n- test case 2\n```\n\n### Suite as array item with test cases\n\n```yaml\n- Suite:\n  - test case 1\n  - test case 2\n```\n\n### Parent suite with as item several child suites (as items)\n\n```yaml\n- Suite:\n  - child suite 1:\n    - test case 1\n    - test case 2\n  - child suite 2:\n    - test case 3\n    - test case 4\n```\n\n### Several parent suites as items with several child suites (as items)\n\n```yaml\n- Parent Suite 1:\n    - child suite 1:\n      - test case 1\n      - test case 2\n    - child suite 2:\n      - test case 3\n      - test case 4\n    \n- Parent Suite 2:\n  - child suite 3:\n    - test case 5\n    - test case 6\n  - child suite 4:\n    - test case 7\n    - test case 8\n```\n\n### Suite object (as object) with test cases\n\n```yaml\nSuite:\n  - test case 1\n  - test case 2\n```\n\n### Parent suite with several child suites (as object)\n\n```yaml\nSuite:\n  child suite 1:\n    - test case 1\n    - test case 2\n  child suite 2:\n    - test case 3\n    - test case 4\n```\n\n### Several parent suites with several child suites (as object)\n\n```yaml\nParent Suite 1:\n  child suite 1:\n    - test case 1\n    - test case 2\n  child suite 2:\n    - test case 3\n    - test case 4\n    \nParent Suite 2:\n  child suite 3:\n    - test case 5\n    - test case 6\n  child suite 4:\n    - test case 7\n    - test case 8\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioncakephper%2Fyaml2test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fioncakephper%2Fyaml2test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioncakephper%2Fyaml2test/lists"}