Coder Social home page Coder Social logo

Comments (9)

dgeb avatar dgeb commented on August 16, 2024

I think that a template-driven integration test that's not exclusive to a particular component has its place. This provides a way to test integration of multiple components and/or views outside of the context of an application.

from ember-test-helpers.

dgeb avatar dgeb commented on August 16, 2024

I suppose I'm proposing that TestModuleForIntegration become TestModuleForTemplate (or something similar) and provide a general sandbox for testing an ad-hoc template.

This sandbox could be an an integration test by default, but have the option of having an isolated container as well.

In this way, the unit vs. integration split remains defined simply by its isolation.

from ember-test-helpers.

ef4 avatar ef4 commented on August 16, 2024

That sounds good. I still think we need a better name -- moduleForTemplate isn't quite right either, because the module doesn't exist to test any particular template. That's more of an implementation detail of the tests themselves.

Maybe we can solve that by dropping the moduleFor naming pattern, which works for particular subjects moduleFor('my-subject') and not so well for this other generic pattern which doesn't require a single subject.

What about templateTestModule?

from ember-test-helpers.

dgeb avatar dgeb commented on August 16, 2024

templateTestModule is an improvement. And I'd be glad to move away from the stilted moduleFor naming pattern altogether. Luckily, it's easy to change as it's encapsulated by ember-mocha and ember-qunit.

from ember-test-helpers.

ef4 avatar ef4 commented on August 16, 2024

I'm thinking ahead to what we name it in those too. That's what motivated this issue, because I was about to submit PRs to those projects to expose this new thing.

from ember-test-helpers.

dgeb avatar dgeb commented on August 16, 2024

Indeed - that's the more important naming question. Hmmmm....

from ember-test-helpers.

ef4 avatar ef4 commented on August 16, 2024

After much thought and discussion, I propose this solution:

  1. Instead of making a new kind of test-module, we fold this new capability into test-module-for-component.
  2. test-module-for-component changes to using integration: true by default, and the presence of an explicit needs option switches it back into unit test mode. We could also offer unit: true and/or integration:false if we want clearer synonyms.
  3. In integration mode, component tests use the style that's currently present in test-module-for-integration. The existing style (render() with no template, subject(), etc) throws deprecation errors. People can upgrade gracefully by just ensuring their existing tests have a needs option (or integration:false or unit:true, depending on which of those we decide to support), which will trigger the existing unit test behavior.
  4. We will want to change the blueprint generators in ember-qunit and ember-mocha to be able to generate both component integration tests (the default) and component unit tests. They would go into different paths (tests/integration/components/foo vs tests/unit/components/foo) and have slightly different boilerplate (the presence or absence of needs).

from ember-test-helpers.

eccegordo avatar eccegordo commented on August 16, 2024

This is fortuitous! I have been struggling a lot with trying to setup component tests that are sensible.

When services, models and other things that ultimately a component depends upon to work, it is a real bear to setup.

How about something like

sandboxForComponent(app, component, dependencies)

The idea here is that your "sandbox" represents a very custom micro app that has everything stubbed and ready for use for testing a component.

app =
would be the sandbox itself with a real-ish application container and registry. One could in theory pass different or multiple app sandboxes into different test files.

component =
would be the explicit component under test

dependencies =
whatever you might subsume under needs, e.g. models, controllers, views, other components, etc.

It would be nice to be able to set these up as part of test configuration or else inline in a specific component test.

from ember-test-helpers.

rwjblue avatar rwjblue commented on August 16, 2024

Closing as @ef4's last proposal has landed and is released.

from ember-test-helpers.

Related Issues (20)

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.