Comments (9)
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.
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.
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.
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.
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.
Indeed - that's the more important naming question. Hmmmm....
from ember-test-helpers.
After much thought and discussion, I propose this solution:
- Instead of making a new kind of test-module, we fold this new capability into test-module-for-component.
- test-module-for-component changes to using
integration: true
by default, and the presence of an explicitneeds
option switches it back into unit test mode. We could also offerunit: true
and/orintegration:false
if we want clearer synonyms. - 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 aneeds
option (orintegration:false
orunit:true
, depending on which of those we decide to support), which will trigger the existing unit test behavior. - 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
vstests/unit/components/foo
) and have slightly different boilerplate (the presence or absence ofneeds
).
from ember-test-helpers.
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.
Closing as @ef4's last proposal has landed and is released.
from ember-test-helpers.
Related Issues (20)
- Missing types for @glimmer/interfaces HOT 3
- element doesn't exist on type TestContext HOT 2
- Property 'element' does not exist on type 'TestContext'. ? HOT 2
- `find` and `findAll` examples are swapped
- Cannot find type definition file for 'ember__test-helpers' after upgrading to v2.9.3 HOT 2
- Regression with `find()` generic type HOT 1
- Rethinking helpers for forms input HOT 2
- Observers not triggered in ember acceptance tests
- [proposal] add hooks support to all dom helpers + settled and wait-until
- Upgrade `registerHook` and `runHooks` as official public APIs HOT 4
- `fillIn` does not work with input values that are decorated with the `readonly` helper HOT 1
- [feature request] pass more information back in error scenarios
- `scrollTo` target type inconsistent with other test helpers
- Setup context fails when using ember-data v4 and a custom resolver
- Allow `waitUntil` to accept a callback that returns a promise HOT 1
- Types missing from version 3 HOT 4
- Anomalies in current published version compared to previous versions HOT 5
- Allow Ember v5
- needed infra maintainence
- 3.2.0 Missing `lookup` and `register` on `Owner` type definition HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-test-helpers.