{"id":13807922,"url":"https://github.com/tomdale/ember-cli-addon-tests","last_synced_at":"2025-04-14T12:53:07.503Z","repository":{"id":57223085,"uuid":"49965798","full_name":"tomdale/ember-cli-addon-tests","owner":"tomdale","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-11T14:40:09.000Z","size":384,"stargazers_count":31,"open_issues_count":41,"forks_count":19,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T02:02:59.476Z","etag":null,"topics":[],"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/tomdale.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}},"created_at":"2016-01-19T16:23:00.000Z","updated_at":"2023-11-29T17:58:08.000Z","dependencies_parsed_at":"2022-08-31T08:31:39.956Z","dependency_job_id":null,"html_url":"https://github.com/tomdale/ember-cli-addon-tests","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdale%2Fember-cli-addon-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdale%2Fember-cli-addon-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdale%2Fember-cli-addon-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomdale%2Fember-cli-addon-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomdale","download_url":"https://codeload.github.com/tomdale/ember-cli-addon-tests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248885401,"owners_count":21177623,"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":[],"created_at":"2024-08-04T01:01:32.199Z","updated_at":"2025-04-14T12:53:07.473Z","avatar_url":"https://github.com/tomdale.png","language":"JavaScript","readme":"# Ember CLI Addon Tests\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/tomdale/ember-cli-addon-tests.svg)](https://greenkeeper.io/)\n[![npm version](https://badge.fury.io/js/ember-cli-addon-tests.svg)](https://badge.fury.io/js/ember-cli-addon-tests)\n[![Build Status - Travis](https://travis-ci.org/tomdale/ember-cli-addon-tests.svg?branch=master)](https://travis-ci.org/tomdale/ember-cli-addon-tests)\n[![Build Status - AppVeyor](https://ci.appveyor.com/api/projects/status/ifp893hf5s6j5uuy/branch/master?svg=true)](https://ci.appveyor.com/project/tomdale/ember-cli-addon-tests/branch/master)\n\nTest helpers for testing Ember CLI addons inside the context of a real\nEmber app.\n\nPreviously, it was difficult to do real integration testing with Ember\nCLI addons because the process of creating a new Ember app is very slow, due\nto the required `npm install` and `bower install` steps.\n\nThis package automates the process of creating a new Ember CLI app and\ncaching its npm and Bower dependencies, so each test run can get a fresh\napp in very little time. Best of all, you'll be testing your addon in a\nreal app so you can catch integration issues early.\n\n**Stability Note**: API likely to change\n\n## Installation\n\n```sh\nnpm install ember-cli-addon-tests --save-dev\n```\n\n## Example\n\n```js\n'use strict';\n\nconst expect = require('chai').expect;\nconst denodeify = require('denodeify');\nconst request = denodeify(require('request'));\nconst AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;\n\ndescribe('serve assets acceptance', function() {\n  this.timeout(300000);\n\n  let app;\n\n  before(function() {\n    app = new AddonTestApp();\n\n    return app.create('dummy')\n      .then(() =\u003e {\n        return app.startServer();\n      });\n  });\n\n  after(function() {\n    return app.stopServer();\n  });\n\n  it('/index.html', function() {\n    return request({\n      url: 'http://localhost:49741',\n      headers: {\n        'Accept': 'text/html'\n      }\n    })\n      .then(response =\u003e {\n        expect(response.statusCode).to.equal(200);\n        expect(response.headers[\"content-type\"]).to.eq(\"text/html\");\n        expect(response.body).to.contain(\"\u003cbody\u003e\");\n      });\n  });\n\n  it('/assets/vendor.js', function() {\n    return request('http://localhost:49741/assets/vendor.js')\n      .then(response =\u003e {\n        expect(response.statusCode).to.equal(200);\n        expect(response.headers[\"content-type\"]).to.eq(\"application/javascript\");\n        expect(response.body).to.contain(\"Ember =\");\n      });\n  });\n\n  it('/assets/dummy.js', function() {\n    return request('http://localhost:49741/assets/dummy.js')\n      .then(response =\u003e {\n        expect(response.statusCode).to.equal(200);\n        expect(response.headers[\"content-type\"]).to.eq(\"application/javascript\");\n        expect(response.body).to.contain(\"this.route('posts')\");\n      });\n  });\n});\n```\n\nSee the [ember-cli-fastboot tests](https://github.com/ember-fastboot/ember-cli-fastboot/tree/master/test)\nfor real world examples.\n\n## Defining a New App\n\nCreates a new app for testing.\n\n```js\nconst AddonTestApp = require('ember-cli-addon-tests').AddonTestApp;\napp = new AddonTestApp();\n```\n\n## Creating the App\n\nThis starts the process of actually creating a new Ember CLI app on\ndisk. The first run may take several minutes while the `npm install`\nhappens. Subsequent runs will be faster. Pass the name of the\napplication as the first argument.\n\n```js\n// returns a promise\napp.create('my-app');\n```\n\n### \"Precooking\" Node Modules\n\nYou can \"precook\" (essentially pre-install) the node modules for the test\napplications by using `scripts/precook-node-modules.js`. This will speed up\ntest runs by configuring a `node_modules` directory that will be reused.\n\n### Options\n\nYou can customize the app by supplying an options hash:\n\n```js\n// returns a promise\napp.create('my-app', {\n  emberVersion: 'release'\n});\n```\n\nThe following options exist:\n\n| option           | description                                                                                   | defaults to         |\n|------------------|-----------------------------------------------------------------------------------------------|---------------------|\n| emberVersion     | Set the ember version the app should be created with, as you would in your `bower.json`       | canary              |\n| emberDataVersion | Set the version of ember-data, as you would in your `package.json`                            | emberjs/data#master |\n| fixturesPath     | The path to look for your fixture files (see below)                                           | test/fixtures       |\n| noFixtures       | Disables the use of fixture files                                                             | false               |\n| skipNpm          | Useful if you want to edit the `package.json` and install later (skips the default blueprint) | false               |\n\n\n### Fixtures\n\nYou will probably want to add files to the Ember application that you\nwant to test your addon with. Ember CLI Addon Tests will automatically\ncopy fixtures on top of the base Ember CLI app, based on the name of the\napplication that you created.\n\nFor example, if you call `app.create('my-app')`, the test helper will\nlook for a file called `test/fixtures/my-app` in your addon's directory\nand will copy them to the test app, overwriting any files that exist.\n\nIf you do not need fixture files in your test, you can disable them by\nspecifying the `noFixtures` option.\n\nOnce the promise resolves, you can inspect the temporary location of the\napp under test via `app.path`:\n\n```js\napp.create('my-app').then(() =\u003e {\n  console.log(app.path);\n  // /var/folders/vc/wjjhq0f542q3dn2109clfy81dlk662/T/d-117613-7500-1bq89dh.8ts6wuq5mi/under-test/my-app\n  // or\n  // C:\\Users\\kelly\\AppData\\Local\\Temp\\d-117613-15884-1j1bw40.5kbh\\under-test\\my-app\n});\n```\n\n## Editing App's `package.json`\n\nIf your addon depends on end developers configuring their application's\n`package.json`, you can edit the test app's `package.json` with the\n`editPackageJSON` method:\n\n```js\n// runs synchronously\napp.editPackageJSON(pkg =\u003e {\n  pkg.devDependencies['fake-addon'] = \"*\";\n  pkg.devDependencies['fake-addon-2'] = \"*\";\n});\n```\n\nYou should not call `app.editPackageJSON()` until after the `create()`\npromise has resolved.\n\n## Starting the Server\n\nTo test the assets served by Ember CLI, you can start the server (i.e.,\n`ember serve`) via the `startServer()` method:\n\n```js\n// returns a promise\napp.startServer();\n```\n\nYou can also pass additional command line arguments via the\n`additionalArguments` option:\n\n```js\n// equivalent to `ember serve -prod`\napp.startServer({\n  additionalArguments: ['-prod']\n});\n```\n\nYou can run your own command like `ember foo` instead of `ember serve`.\nThen you need to tell it what to look for in the console to know it is ready.:\n\n```js\napp.startServer({\n  command: 'foo',\n  detectServerStart(output) {\n    return output.indexOf('foo is ready') \u003e -1;\n  }\n});\n```\n\n## Stopping the Server\n\nAfter your tests, stop the development server via `stopServer()`.\n\n```js\napp.stopServer();\n```\n\n## Running Commands\n\nYou can run arbitrary commands inside the test app via the `run()`\nmethod. Takes a command and optional arguments.\n\n```js\n// returns a promise\napp.run('ember', 'build', '--verbose');\n```\n\n## Running Ember CLI Commands\n\nYou can run commands using the app's version of Ember CLI via the\n`runEmberCommand` method:\n\n```js\n// equivalent to `ember build --environment production`\napp.runEmberCommand('build', '--environment', 'production');\n```\n\n## Cleanup\n\nTemporary directories are automatically deleted once the process exits.\n","funding_links":[],"categories":["Packages"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdale%2Fember-cli-addon-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomdale%2Fember-cli-addon-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomdale%2Fember-cli-addon-tests/lists"}