Code Monkey home page Code Monkey logo

Comments (4)

mjuniper avatar mjuniper commented on June 14, 2024 1

Ok, this seems to work but I'll bet there's a better way:

import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import sanitizer from 'my-app/sanitizers/links-only';

moduleForComponent('my-component', 'Integration | Component | my component', {
  integration: true,

  setup() {
    this.container.registry.register('sanitizer:links-only', Ember.Object.extend(sanitizer));
  }
});

test('it renders', function(assert) {
  ...
});

from ember-sanitize.

rlivsey avatar rlivsey commented on June 14, 2024

I've done this before, but remember it being a bit evil when I did it too & having to go through the container (now registry) like you're doing.

The problem is, as you've seen, that initializers aren't run in component tests as the app isn't booted.

I'll ask around and see what the best way of doing it is. I wonder if there's a way for the addon to hook into the tests so it sets up the initializer for you automagically?

from ember-sanitize.

jcano avatar jcano commented on June 14, 2024

I'm having this issue too, @rlivsey have you figured out the best way of testing?

from ember-sanitize.

pogopaule avatar pogopaule commented on June 14, 2024

I wrote my integration test like this:

...
import sanitizeInitializer from 'my-app/initializers/setup-sanitizers';

moduleForComponent('foo-bar', 'Integration - pods/components/foo-bar', {
  integration: true,
  beforeEach() {
    sanitizeInitializer.initialize(this.container.registry);
  }
});

from ember-sanitize.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.