I have an app for which page reloads / navigation and iframes are crucial and those part seem very tricky to cover with unit tests.
I want to be able to write smt. like this:
it('should fire appropriate callbacks on start and page reload', function() {
app.start();
expect(app.onStart).toHaveBeenCalled();
page.reload();
expect(app.onRestart).toHaveBeenCalled();
}
it('should know whether it runs in iframe or not', function() {
expect(app.isInIframe()).toBe(false);
iframe = createTestIframe();
expect(iframe.getApp().isInIframe()).toBe(true);
}
Unit testing frameworks I know of (mocha, Jasmine, QUnit) are all designed to do entire test suite on one page, in top context.
On the other hand, functional testing frameworks (FuncUnit, TestCafé, Selenium WebDriver) seem to focus on high-level abstractions, such as "click an element", "check element's value" etc, not giving an ability to dig into code execution.
Disclaimer: I'm rather new to testing in general, so maybe I should look at the problem from a different perspective altogether.