Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ember-cli-pretender with all npm packages installed. Try it out:

var emberCliPretender = require("ember-cli-pretender")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ember-cli-pretender v3.1.1

Include Pretender into an ember-cli application.

ember-cli-pretender

Simple wrapper for pretender.js, this project removes the need for the developer to know which files need to be imported.

Usage

ember install ember-cli-pretender

You can then import Pretender in your tests:

import Pretender from 'pretender';

see: pretenderjs/pretender for pretender docs

Configuration

By default pretender.enabled will be set to app.tests. This means that pretender will only be available as an import when your app includes your test suite.

If you'd like to include Pretender into production builds as well, you can set pretender.enabled to true in your ember-cli-build.js or Brocfile.js:

var app = new EmberApp({
  pretender: {
    enabled: true
  }
});

You can also opt out of including the fetch polyfill, if you do not need to run your tests in older browsers:

var app = new EmberApp({
  pretender: {
    includeFetchPolyfill: false
  }
});

Nested Addon Usage Caveat

To publish an addon that exports functionality driven by ember-cli-pretender, note that ember-cli-pretender must be listed in the dependencies for NPM and not the devDependencies.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free