dimanche 5 avril 2020

ember octane testing: env.locationType not working

I'm noticing this.transitionTo() methods in my code are changing the actual address URL in my Ember 3.16 test server window.

I made sure that my ENV.locationType=none. Can someone spot something really obvious that I'm missing?

config/environment.js:

module.exports = function (environment) {
  let ENV = {
    modulePrefix: "portal-client3",
    environment,
    rootURL: "/",
    locationType: "auto",
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false,
      },
    },

    APP: {},
  };

  if (environment === "test") {
    ENV.locationType = "none";
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;
    ENV.APP.rootElement = "#ember-testing";
    ENV.APP.autoboot = false;
  }
  return ENV;
};

app/router:

import EmberRouter from "@ember/routing/router";
import config from "./config/environment";

export default class Router extends EmberRouter {
  location = config.locationType;
  rootURL = config.rootURL;
}

tests/test-helper:

import Application from "../app";
import config from "../config/environment";
import { setApplication } from "@ember/test-helpers";
import { start } from "ember-qunit";

setApplication(Application.create(config.APP));
start();

tests/acceptance/login-test:

import { module, test } from "qunit";
import { visit, currentURL } from "@ember/test-helpers";
import { setupApplicationTest } from "ember-qunit";
import { setupMirage } from "ember-cli-mirage/test-support";

module("Acceptance | login", function (hooks) {
  setupApplicationTest(hooks);
  setupMirage(hooks);

  test("visiting /login", async function (assert) {
    await visit("/clientname");
    assert.equal(currentURL(), "/clientname/login");
  });
});




Aucun commentaire:

Enregistrer un commentaire