-
Notifications
You must be signed in to change notification settings - Fork 159
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
move to vitest #235
move to vitest #235
Conversation
@@ -191,11 +191,11 @@ class MixpanelPeople extends ProfileHelpers() { | |||
*/ | |||
track_charge(distinct_id, amount, properties, modifiers, callback) { | |||
if (typeof(properties) === 'function' || !properties) { | |||
callback = properties || function() {}; | |||
callback = properties || undefined; |
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.
make sure the callback is conditionally passed in send_request
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.
Awesome. Surprised to see coverage is already so good. Just a bit of cleanup suggested but largely good to go
test/alias.js
Outdated
describe('alias', () => { | ||
let mixpanel; | ||
let sendRequestMock; | ||
beforeAll(() => { |
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.
beforeAll(() => { | |
beforeEach(() => { |
test/config.js
Outdated
|
||
describe('config', () => { | ||
let mixpanel; | ||
beforeAll(() => { |
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 would also make this one a beforeEach
- make sure each test case has a fresh mp instance
test/import.js
Outdated
|
||
"calls send_request with correct endpoint and data": function(test) { | ||
var event = "test", | ||
six_days_ago_timestamp = mock_now_time - 1000 * 60 * 60 * 24 * 6; |
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.
six_days_ago_timestamp = mock_now_time - 1000 * 60 * 60 * 24 * 6; | |
six_days_ago_timestamp = mock_now_time - 1000 * 60 * 60 * 24 * 6; |
test/import.js
Outdated
|
||
describe('import', () => { | ||
let mixpanel; | ||
beforeAll(() => { |
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.
beforeAll(() => { | |
beforeEach(() => { |
test/import.js
Outdated
|
||
vi.spyOn(mixpanel, 'send_request'); | ||
}), | ||
afterAll(() => { |
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.
return this func from the before-func, for consistency with your other tests
test/import.js
Outdated
|
||
next(); | ||
}, | ||
afterEach(() => { |
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.
return from before-func
test/people.js
Outdated
send_request = vi.fn(); | ||
|
||
mixpanel = Mixpanel.init(token); | ||
mixpanel.send_request = send_request |
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.
Seems like you're inconsistent between using this approach and vi.spyOn(mixpanel, 'send_request')
. I would think spyOn is preferable, but is there some context I'm missing?
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.
good catch.. i think when i did the conversion, this was the way sinon stubs this function.
test/send_request.js
Outdated
let mixpanel; | ||
let http_emitter; | ||
let res; | ||
beforeEach((next) => { |
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.
beforeEach((next) => { | |
beforeEach(() => { |
var event = "test", | ||
describe('track', () => { | ||
let mixpanel; | ||
beforeAll(() => { |
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.
beforeAll(() => { | |
beforeEach(() => { |
@tdumitrescu updated |
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.
🎉
vitest requires node version 18. so updated workflow.yaml as well.