{"id":28972563,"url":"https://github.com/ember-cli/ember-cli-blueprint-test-helpers","last_synced_at":"2025-06-24T11:06:57.214Z","repository":{"id":1724743,"uuid":"43797618","full_name":"ember-cli/ember-cli-blueprint-test-helpers","owner":"ember-cli","description":"Test helpers for testing ember-cli blueprints","archived":false,"fork":false,"pushed_at":"2025-01-28T16:14:17.000Z","size":1199,"stargazers_count":23,"open_issues_count":23,"forks_count":15,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-06-14T04:38:44.139Z","etag":null,"topics":["ember-cli"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ember-cli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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,"zenodo":null},"funding":{"github":"emberjs","open_collective":"emberjs"}},"created_at":"2015-10-07T05:52:12.000Z","updated_at":"2025-01-28T16:14:22.000Z","dependencies_parsed_at":"2025-04-13T09:32:17.958Z","dependency_job_id":"0e4c50f0-0819-4c9c-9b92-d72738410fbd","html_url":"https://github.com/ember-cli/ember-cli-blueprint-test-helpers","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/ember-cli/ember-cli-blueprint-test-helpers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fember-cli-blueprint-test-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fember-cli-blueprint-test-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fember-cli-blueprint-test-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fember-cli-blueprint-test-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-cli","download_url":"https://codeload.github.com/ember-cli/ember-cli-blueprint-test-helpers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli%2Fember-cli-blueprint-test-helpers/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260577241,"owners_count":23030690,"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":["ember-cli"],"created_at":"2025-06-24T11:06:56.485Z","updated_at":"2025-06-24T11:06:57.198Z","avatar_url":"https://github.com/ember-cli.png","language":"JavaScript","funding_links":["https://github.com/sponsors/emberjs","https://opencollective.com/emberjs"],"categories":[],"sub_categories":[],"readme":"\nember-cli-blueprint-test-helpers\n==============================================================================\n\n[![npm version](https://badge.fury.io/js/ember-cli-blueprint-test-helpers.svg)](https://badge.fury.io/js/ember-cli-blueprint-test-helpers)\n[![GitHub Actions Build Status](https://github.com/ember-cli/ember-cli-blueprint-test-helpers/workflows/CI/badge.svg)](https://github.com/ember-cli/ember-cli-blueprint-test-helpers/actions/workflows/ci.yml)\n\ntest helpers for [ember-cli](https://github.com/ember-cli/ember-cli) blueprints\n\n\nInstallation\n------------------------------------------------------------------------------\n\n```\nember install ember-cli-blueprint-test-helpers\n```\n\nIt should be noted that `ember-cli-blueprint-test-helpers` currently\n[only works for testing blueprints inside addon projects](https://github.com/ember-cli/ember-cli-blueprint-test-helpers/issues/56).\n\nUsage\n------------------------------------------------------------------------------\n\n### Running Tests\n\nThe blueprint tests can be run by:\n\n```\nnode_modules/.bin/mocha node-tests --recursive\n```\n\nFor convenience you should add the following to your `package.json`:\n\n```json\n\"scripts\": {\n  \"nodetest\": \"mocha node-tests --recursive\"\n}\n```\n\nto be able to use `npm run nodetest` to run the tests.\n\n\n### Generating Tests\n\nGenerate a blueprint test scaffold using the `blueprint-test` generator:\n\n```\nember generate blueprint-test my-blueprint\n```\n\nwhich will generate a test file at `node-tests/blueprints/my-blueprint-test.js`.\n\n\n### Example Usage\n\n```js\nconst { \n  setupTestHooks,\n  emberNew,\n  emberGenerateDestroy,\n} = require('ember-cli-blueprint-test-helpers/helpers');\n\nconst {\n  expect\n} = require('ember-cli-blueprint-test-helpers/chai');\n\ndescribe('Acceptance: ember generate and destroy my-blueprint', function() {\n  // create and destroy temporary working directories\n  setupTestHooks(this);\n\n  it('my-blueprint foo', function() {\n    const args = ['my-blueprint', 'foo'];\n\n    // create a new Ember.js app in the working directory\n    return emberNew()\n\n      // then generate and destroy the `my-blueprint` blueprint called `foo`\n      .then(() =\u003e emberGenerateDestroy(args, (file) =\u003e {\n\n        // and run some assertions in between\n        expect(file('path/to/file.js'))\n          .to.contain('file contents to match')\n          .to.contain('more file contents\\n');\n      }));\n\n     // magically done for you: assert that the generated files are destroyed again\n  });\n});\n```\n\nor more explicitly:\n\n```js\nconst { \n  setupTestHooks,\n  emberNew,\n  emberGenerate,\n  emberDestroy,\n} = require('ember-cli-blueprint-test-helpers/helpers');\n\nconst {\n  expect,\n  file,\n} = require('ember-cli-blueprint-test-helpers/chai');\n\ndescribe('Acceptance: ember generate and destroy my-blueprint', function() {\n  // create and destroy temporary working directories\n  setupTestHooks(this);\n\n  it('my-blueprint foo', function() {\n    const args = ['my-blueprint', 'foo'];\n\n    // create a new Ember.js app in the working directory\n    return emberNew()\n\n      // then generate the `my-blueprint` blueprint called `foo`\n      .then(() =\u003e emberGenerate(args))\n\n      // then assert that the files were generated correctly\n      .then(() =\u003e expect(file('path/to/file.js'))\n        .to.contain('file contents to match')\n        .to.contain('more file contents\\n'))\n\n      // then destroy the `my-blueprint` blueprint called `foo`\n      .then(() =\u003e emberDestroy(args))\n\n      // then assert that the files were destroyed correctly\n      .then(() =\u003e expect(file('path/to/file.js')).to.not.exist);\n  });\n});\n```\n\nAPI Reference\n------------------------------------------------------------------------------\n\nThis project exports two major API endpoints for you to use:\n\n- `require('ember-cli-blueprint-test-helpers/chai')`\n\n  This endpoint exports the [Chai](http://chaijs.com/) assertion library\n  including the [chai-as-promised](https://github.com/domenic/chai-as-promised)\n  and [chai-files](https://github.com/Turbo87/chai-files) plugins\n\n- `require('ember-cli-blueprint-test-helpers/helpers')`\n\n  This endpoint exports the functions mentioned in the following API reference\n\n---\n\n### `setupTestHooks(scope, options)`\n\nPrepare the test context for the blueprint tests.\n\n**Parameters:**\n\n- `{Object} scope` the test context (i.e. `this`)\n- `{Object} [options]` optional parameters\n- `{Number} [options.timeout=20000]` the test timeout in milliseconds\n- `{Object} [options.tmpenv]` object containing info about the temporary directory for the test.\n- `{String} [options.cliPath='ember-cli']` path to the `ember-cli` dependency\n- `{Boolean} [options.disabledTasks=['addon-install', 'bower-install', 'npm-install']]` override the mocked installs\n  Defaults to [`lib/helpers/tmp-env.js`](lib/helpers/tmp-env.js)\n\n**Returns:** `{Promise}`\n\n---\n\n### `emberNew(options)`\n\nCreate a new Ember.js app or addon in the current working directory.\n\n**Parameters:**\n\n- `{Object} [options]` optional parameters\n- `{String} [options.target='app']` the type of project to create (`app`, `addon` or `in-repo-addon`)\n- `{string[]} [options.extraCliArgs=[]]` any extra arguments you want to pass to ember-cli\n\n**Returns:** `{Promise}`\n\n---\n\n### `emberGenerate(args)`\n\nRun a blueprint generator.\n\n**Parameters:**\n\n- `{Array.\u003cString\u003e} args` arguments to pass to `ember generate` (e.g. `['my-blueprint', 'foo']`)\n\n**Returns:** `{Promise}`\n\n---\n\n### `emberDestroy(args)`\n\nRun a blueprint destructor.\n\n**Parameters:**\n\n- `{Array.\u003cString\u003e} args` arguments to pass to `ember destroy` (e.g. `['my-blueprint', 'foo']`)\n\n**Returns:** `{Promise}`\n\n---\n\n### `emberGenerateDestroy(args, assertionCallback)`\n\nRun a blueprint generator and the corresponding blueprint destructor while\nchecking assertions in between.\n\n**Parameters:**\n\n- `{Array.\u003cString\u003e} args` arguments to pass to `ember generate` (e.g. `['my-blueprint', 'foo']`)\n- `{Function} assertionCallback` the callback function in which the assertions should happen\n\n**Returns:** `{Promise}`\n\n---\n\n### `modifyPackages(packages)`\n\nModify the dependencies in the `package.json` file of the test project.\n\n**Parameters:**\n\n- `{Array.\u003cObject\u003e} packages` the list of packages that should be added,\n  changed or removed\n\n---\n\n### `setupPodConfig(options)`\n\nSetup `usePods` in `.ember-cli` and/or `podModulePrefix` in `environment.js`.\n\n**Parameters:**\n\n- `{Object} [options]` optional parameters\n- `{Boolean} [options.usePods]` add `usePods` in `.ember-cli`\n- `{Boolean} [options.podModulePrefix]` set `npodModulePrefix` to `app/pods`\n  in `config/environment.js`\n\n\nUsed by\n------------------------------------------------------------------------------\n\n- https://github.com/emberjs/ember.js\n- https://github.com/emberjs/data\n- https://github.com/ember-cli/ember-cli-legacy-blueprints\n- https://github.com/simplabs/ember-simple-auth\n- https://github.com/DockYard/ember-suave\n\n\nLicense\n------------------------------------------------------------------------------\n\nThis project is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli%2Fember-cli-blueprint-test-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-cli%2Fember-cli-blueprint-test-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli%2Fember-cli-blueprint-test-helpers/lists"}