{"id":24505743,"url":"https://github.com/ioncakephper/yamlspec","last_synced_at":"2025-07-04T04:35:47.220Z","repository":{"id":54105318,"uuid":"345958005","full_name":"ioncakephper/yamlspec","owner":"ioncakephper","description":"Generate Jasmine-compatible .js specification files from .yaml-formatted specification file","archived":false,"fork":false,"pushed_at":"2021-09-24T06:30:41.000Z","size":1490,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T23:33:32.094Z","etag":null,"topics":["generated-code","jasmine","spec","test","test-automation","testing-tools","yaml"],"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":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-09T09:50:33.000Z","updated_at":"2021-09-24T06:30:43.000Z","dependencies_parsed_at":"2022-08-13T06:50:29.994Z","dependency_job_id":null,"html_url":"https://github.com/ioncakephper/yamlspec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyamlspec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyamlspec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyamlspec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ioncakephper%2Fyamlspec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ioncakephper","download_url":"https://codeload.github.com/ioncakephper/yamlspec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243707298,"owners_count":20334614,"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":["generated-code","jasmine","spec","test","test-automation","testing-tools","yaml"],"created_at":"2025-01-21T23:31:28.650Z","updated_at":"2025-03-15T08:42:17.278Z","avatar_url":"https://github.com/ioncakephper.png","language":"JavaScript","readme":"# yamlspec\n\nGenerates `JavaScript` package specification files from a `.yml` specification file, giving both developers and QA team a quick and productive tool for writing specifications.  \n\n## Installation\n\nInstall `yamlspec` globally so you can invoke it as command-line program:\n\n```bash\nnpm i -g yamlspec\n```\n\nCheck `yamlspec` runs at command-prompt:\n\n```bash\nyamlspec -V\nv1.0.5\n```\n\n## YML-format specifications\n\nTo expedite specification formulation process, `yamlspec` introduces its alternative to traditional `.js` code. Those familiar with `Jasmine` and its related specification frameworks based on `.js` will recognize the `describe` and `it` entries.\n\nThe example below contains specifications for `\u003cpackageName\u003e` package, which is invoked with a `require` statement. The package is placed in a constant whose name is also `\u003cpackageName\u003e`.\n\nThe specification contains two `describe` sections, aka \"test sets\", inside the `items` key. Each section contains its own test cases as `it` entries. The test cases fall under a test set's `items`.\n\n```yaml\npackage:\n    - require: \u003cpackageName\u003e\n    - const: \u003cpackageName\u003e\nitems:\n    - describe:\n        what: \u003cpackageName\u003e\n        items:\n            - it: should have method a\n    - describe:\n        what: method a\n        items:\n            - it: should return a string\n            - it: should return an empty string when input parameter is empty\n            - it: should return en empty string when input parameter is not specified\n            - it: should return an empty string when input parameter has only delimiters \n```\n\n## JavaScript Code\n\n```js\nconst yamlspec = require('yamlspec')\n\nlet sourceFilename = '/path/to/specsInYamlFormat.yml';\n\nlet source = yamlspec.loadFile(sourceFilename)\nyamlspec.renderFile('/path/to/spec/folder/specfilename.js', source);\n```\n\n## CLI\n\n```bash\nyamlspec [options] sourceFilename\n```\n```bash\nyamlspec -h\nUsage: yamlspec [options] sourceFilename\n\nYAML to Jasmine specification generator.\n\nOptions:\n  -V, --version                      output the version number\n  -o, --output \u003coutfilename\u003e         name of extended specification filename\n  -s, --suffix \u003csuffix\u003e              suffix text to go after test basename (default: \"Spec\")\n  -p, --path \u003coutpath\u003e               root path for generated specification files (default: \"./spec\")\n  -t, --templatepath \u003ctemplatepath\u003e  path to templates (default: \".\\\\bin\\\\templates\")\n  -h, --help                         display help for command\n```\n\n\n## Examples\n\n1. Create your working folder with `mkdir myfolder`, `cd myfolder`, and create `mypackage.yml` as follows:\n\n```yaml\npackage:\n    request: fs\n    const: fs\n\nitems:\n    - describe:\n        what: Simple test suite\n        items:\n            - it: First test description\n            - it: Second test description\n            - it: Third test description\n```\n\n2. Run `yamlspec`\n\n```bash\nyamlspec mypackage\n```\n\n`yamlspec` generates the `./spec/mypackageSpec.js`\n\n```js\nconst fs = require('fs');\n\ndescribe('Simple test suite', () =\u003e {\n\n    // First test description\n    it('First test description', () =\u003e {\n        //\n        // @todo First test description\n        //\n        expect(0).toEqual(1)\n    })\n\n    // Second test description\n    it('First test description', () =\u003e {\n        //\n        // @todo Second test description\n        //\n        expect(0).toEqual(1)\n    })\n\n    // Third test description\n    it('Third test description', () =\u003e {\n        //\n        // @todo Third test description\n        //\n        expect(0).toEqual(1)\n    })\n})\n```\n\n3. Invoke `Jasmine`, confirming your specifications are available. All will fail.\n\n```bash\njasmine\n```\n\n## API\n### Functions\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#loadFile\"\u003eloadFile(sourceFilename, [options])\u003c/a\u003e ⇒ \u003ccode\u003eObject\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eLoad source file with YAML specification.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#render\"\u003erender(source, [options])\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eRender extended specification content.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003ca href=\"#renderFile\"\u003erenderFile(outputFilename, source, [options])\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eRender file with exptended specification content.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"loadFile\"\u003e\u003c/a\u003e\n\n### loadFile(sourceFilename, [options]) ⇒ \u003ccode\u003eObject\u003c/code\u003e\nLoad source file with YAML specification.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003eObject\u003c/code\u003e - Specification object.  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| sourceFilename | \u003ccode\u003estring\u003c/code\u003e |  | Source filename in .yaml format |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e | \u003ccode\u003e{}\u003c/code\u003e | File loading options. |\n\n\u003ca name=\"render\"\u003e\u003c/a\u003e\n\n### render(source, [options]) ⇒ \u003ccode\u003estring\u003c/code\u003e\nRender extended specification content.\n\n**Kind**: global function  \n**Returns**: \u003ccode\u003estring\u003c/code\u003e - Expanded resulting specification content.  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| source | \u003ccode\u003eObject\u003c/code\u003e |  | Specification object. |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e | \u003ccode\u003e{}\u003c/code\u003e | Rendering options. |\n\n\u003ca name=\"renderFile\"\u003e\u003c/a\u003e\n\n### renderFile(outputFilename, source, [options])\nRender file with exptended specification content.\n\n**Kind**: global function  \n\n| Param | Type | Default | Description |\n| --- | --- | --- | --- |\n| outputFilename | \u003ccode\u003estring\u003c/code\u003e |  | Path-like string of output filename. |\n| source | \u003ccode\u003eObject\u003c/code\u003e |  | Specification object. |\n| [options] | \u003ccode\u003eObject\u003c/code\u003e | \u003ccode\u003e{}\u003c/code\u003e | Rendering options. |\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioncakephper%2Fyamlspec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fioncakephper%2Fyamlspec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fioncakephper%2Fyamlspec/lists"}