My app uses [email protected] for authorization, with a (for now) mirage backend that handles the auth request. It works fine when I run the application. Now I'm trying to test the authentication workflow in an acceptance test. I have a secure route as / with an auth check that redirects to the /login route:
export default class SecureRoute extends Route {
@service declare session: any;
async beforeModel(transition: Transition): Promise<void> {
await this.session.requireAuthentication(transition, 'login');
}
}
My test looks like this:
@suite('Acceptance | login')
export class LoginAcceptanceTest extends MirageApplicationTest {
@test async 'validating login'(assert: Assert): Promise<void> {
await visit('/');
assert.equal(currentURL(), '/login');
When I debug I can see that the login route is loaded, but I get the following error:
Source: | Error: TransitionAborted
at handleTransitionReject (http://localhost:7357/assets/vendor.js:35151:17)
at invokeCallback (http://localhost:7357/assets/vendor.js:65110:17)
at publish (http://localhost:7357/assets/vendor.js:65093:9)
at publishRejection (http://localhost:7357/assets/vendor.js:65029:5)
at http://localhost:7357/assets/vendor.js:59533:53
at invoke (http://localhost:7357/assets/vendor.js:57736:16)
at Queue.flush (http://localhost:7357/assets/vendor.js:57627:13)
at DeferredActionQueues.flush (http://localhost:7357/assets/vendor.js:57824:21)
at Backburner._end (http://localhost:7357/assets/vendor.js:58358:34)
at Backburner._boundAutorunEnd (http://localhost:7357/assets/vendor.js:58027:14)
I ran into this, too. I believe it's related to this larger issue: https://github.com/emberjs/ember-test-helpers/issues/332#issuecomment-689596427
I was able to work around it using the try/catch and check e.message solution for the one test I needed it for.
Hope this helps.
This isn't related to ESA most likely, the issue has been going on for some time like @chadian mentioned.
I've been using this workaround with success https://github.com/emberjs/ember-test-helpers/issues/332#issuecomment-414641697
Not an ESA issue