-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I'm submitting a:
- Bug report
- Feature request
- Other (Describe below)
Current behavior
Tests either fail because they don't have Auth installed, or try to use the real Auth.
Expected behavior
It would be great to have a fake Vue plugin for Okta auth. Example usage might look like:
import { assert } from "chai";
import { createLocalVue, mount } from "@vue/test-utils";
import MyView from "@views/MyView.vue";
import FakeOktaPlugin from "@okta/okta-vue-testing";
const localVue = createLocalVue();
localVue.use(FakeOktaPlugin);
describe("MyView.vue", () => {
it("shows an error when not authenticated", () => {
// need some way to vary behavior by test case
FakeOktaPlugin.fakeAuth.setAuthenticated(false);
// now my view can be created and think it's interacting with `$auth`
const wrapper = mount(MyView, ...etc...);
// verify that my view did the right thing based on auth state, tokens, etc
assert.match(wrapper.text(), /not authenticated/);
});
});This would allow testing components that use $auth, with configurable behavior from the okta-vue plugin.
The implementation could presumably be similar to the real plugin with an install function, but then have simple setters/getters instead of the full Auth implementation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels