Closed suneelv closed 7 years ago
You need to actually use the component testing library to test components. See docs here: http://aurelia.io/hub.html#/doc/article/aurelia/testing/latest/testing-components
I don't want to test the custom element's view. Is it not possible to just test a custom element's view model? http://patrickwalters.net/unit-testing-your-es6-view-models-my-best-practices-for-aurelia/ I know the above article is old, but it seems like a reasonable way to test view models.
If that is not an option, then it would be great if we can do shallow rendering (#20).
Bindables require runtime infrastructure. That's why you have to use the testing framework. It has nothing to do with the view.
@EisenbergEffect thanks for the info. I will comment on the other referenced issue as that is the reason which made us try to test our custom elements in this way
I'm submitting a bug report
Please tell us about your environment:
Operating System: OSX
Node Version: 7.9.0
NPM Version: 4.2.0
JSPM OR Webpack AND Version webpack 2.6.1
Browser: all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView
Language: ESNext
Current behavior:
propertyChanged method is never called in a unit test. Here is a sample custom element view model
Here is my sample test case:
After I set the name of the view model, the nameChanged method is not called and test fails.
Expected/desired behavior:
nameChanged
method should be called when the bindable propertyname
is changed.