-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OKTA-656562 karma to jest #3418
OKTA-656562 karma to jest #3418
Conversation
0e74b1b
to
c96c8da
Compare
@@ -7,7 +7,7 @@ export TEST_RESULT_FILE_DIR="${REPO}/build2/reports/unit" | |||
echo $TEST_SUITE_TYPE > $TEST_SUITE_TYPE_FILE | |||
echo $TEST_RESULT_FILE_DIR > $TEST_RESULT_FILE_DIR_FILE | |||
|
|||
if ! yarn test --type jest --runInBand; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was --runInBand
causing issues? This is actually good though since it should run tests concurrently (faster overall)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, using the --runInBand
flag caused the test to timeout (it took > 30mins to actually complete). When I looked up what the flag was meant for I realized we did not need it in bacon (only during debuggin). This decreased the time to ~10 mins
test/unit/jest/jest-setup-global.js
Outdated
|
||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; | ||
global.crypto = new Crypto(); | ||
global.$ = global.jQuery = $; | ||
global.DEBUG = false; | ||
global.getJasmineRequireObj = function jestSetupGlobalJasmine() { | ||
return jasmine; | ||
}; | ||
global.jasmine = jasmine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should follow up separately to remove jasmine
as it's very confusing to know if a call to something like spyOn
is from jasmine
or from jest
. Additionally, the interface of the returned Spy object is different between jasmine and jest's versions so would be good to migrate so we don't need to keep jasmine in our devDeps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will create a ticket for this, maybe we can actually add it as another UI Guild rotation task 🤔
// Verify tooltip is gone | ||
expect(test.form.isSecurityImageTooltipDestroyed()).toBe(true); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the deleted tests in this file moved someplace else or are they removed entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes sir, moved into the PrimaryAuthForm_spec.js testcafe spec: https://github.com/okta/okta-signin-widget/pull/3418/files#diff-7fc65ff7a9deb6e52de14ecbe846e256708dd5e763b6a70031bd7cbe0f57a5b7R120-R226
.then(function() { | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: true })); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into PrimaryAuthForm_spec.js testcafe spec: https://github.com/okta/okta-signin-widget/pull/3418/files#diff-7fc65ff7a9deb6e52de14ecbe846e256708dd5e763b6a70031bd7cbe0f57a5b7R120-R226
@@ -3296,7 +3198,7 @@ Expect.describe('PrimaryAuth', function() { | |||
// cannot mock it because we defer to AuthJs to do set window.location. | |||
// On the plus side, there is an e2e test that covers this. | |||
// eslint-disable-next-line jasmine/no-disabled-tests | |||
xit('redirects to the correct url in the social idp redirect flow'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this stay uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting this since there is already an e2e test that covers this.
// patch jquery 3 visible pseudos selector issue in jsdom | ||
// https://github.com/jsdom/jsdom/issues/1048#issuecomment-401599392 | ||
// https://github.com/jsdom/jsdom/issues/1048#issuecomment-595961496 | ||
window.Element.prototype.getClientRects = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any workaround to avoiding using jquery to do the check for :visible
instead of having to polyfill this behavior for jsdom?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to upate code within Gen 1 to not use the visible selector, this is one example where we are using the visible selector, but it is also used by JQuery qtip.
itp('sets aria-expanded attribute correctly when clicking help', function() { | ||
return setup().then(function(test) { | ||
expect(test.form.helpFooter().attr('aria-expanded')).toBe('false'); | ||
test.form.helpFooter().click(); | ||
expect(test.form.helpFooter().attr('aria-expanded')).toBe('true'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into PrimaryAuthForm_spec.js
itp('does not show anti-phishing message if security image is hidden', function() { | ||
return setup({ features: { securityImage: true } }) | ||
.then(function(test) { | ||
test.setNextResponse(resSecurityImageFail); | ||
test.form.securityBeaconContainer().hide(); | ||
spyOn($.qtip.prototype, 'toggle').and.callThrough(); | ||
test.form.setUsername('testuser@clouditude.net'); | ||
$(window).trigger('resize'); | ||
return waitForBeaconChange(test); | ||
}) | ||
.then(function(test) { | ||
expect($.qtip.prototype.toggle.calls.count()).toBe(1); | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: false })); | ||
$.qtip.prototype.toggle.calls.reset(); | ||
test.form.securityBeaconContainer().show(); | ||
$(window).trigger('resize'); | ||
return Expect.waitForSpyCall($.qtip.prototype.toggle); | ||
}) | ||
.then(function() { | ||
expect($.qtip.prototype.toggle.calls.count()).toBe(1); | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: true })); | ||
}); | ||
}); | ||
itp('show anti-phishing message if security image become visible', function() { | ||
return setup({ features: { securityImage: true } }) | ||
.then(function(test) { | ||
spyOn($.qtip.prototype, 'toggle').and.callThrough(); | ||
test.setNextResponse(resSecurityImageFail); | ||
test.form.setUsername('testuser@clouditude.net'); | ||
return waitForBeaconChange(test); | ||
}) | ||
.then(function(test) { | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: true })); | ||
$.qtip.prototype.toggle.calls.reset(); | ||
test.form.securityBeaconContainer().hide(); | ||
$(window).trigger('resize'); | ||
return Expect.waitForSpyCall($.qtip.prototype.toggle, test); | ||
}) | ||
.then(function(test) { | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: false })); | ||
$.qtip.prototype.toggle.calls.reset(); | ||
test.form.securityBeaconContainer().show(); | ||
$(window).trigger('resize'); | ||
return Expect.waitForSpyCall($.qtip.prototype.toggle, test); | ||
}) | ||
.then(function() { | ||
expect($.qtip.prototype.toggle.calls.argsFor(0)).toEqual(jasmine.objectContaining({ 0: true })); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d2a5958
to
5e8b814
Compare
test/unit/spec/v1/EnrollCall_spec.js
Outdated
testEnrollPhoneNumber(setup, resEnrollSuccess); | ||
}); | ||
|
||
describe('Verify phone number', function() { | ||
beforeEach(() => { | ||
jest.setTimeout(20000); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking also to see if these extra timeouts can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep these can be removed, pushing update and did a search for all usage of this settimeout to test the removal of those as well 🙏
test/unit/helpers/dom/Dom.js
Outdated
|
||
// jsdom has issue with :visible selector | ||
// check visibility recursively instead | ||
if (global.useJest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this conditional and the "jquery method" now? i see the jest setup file sets this true
1423e45
to
fc0d5cf
Compare
Description:
The purpose of this PR is to migrate all tests that currently use karma (referenced in legacy-tests.js) to use jest and to remove all karma dependencies.
PR Checklist
Issue:
Reviewers:
Screenshot/Video:
Downstream Monolith Build: