Skip to content
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

Fix unit tests #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Fix unit tests #13

wants to merge 5 commits into from

Conversation

mdvorscak
Copy link

Fixes #12

Switched to karma chrome headless sinon

package.json Outdated
@@ -43,5 44,14 @@
"gulp-rename": "^1.2.2",
"mocha": "^3.0.1",
"run-sequence": "^1.2.2"
},
"dependencies": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be devDependencies

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to get rid of "chai" and "mocha" deps? Do the "karma-*" deps cover those?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested it, we can get rid of mocha. But chai and sinon are not covered by karma-*

metric.sendToAnalytics('category_name', 'metric_name', 1234567890);
assert(spy.calledWith('send', 'timing', 'category_name', 'metric_name', 1234567890));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are testing that the GA api call is made, not that the entries are properly recorded in the PerformanceObserver. Can we keep the tests as is? Think that means removing sinon....?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried leaving it as it was. However, when I first ran the tests they always failed. They were sending the wrong payload, metric.name was always google-analytics.com/analytics.js (or some variation of the GA script address).

The tests were previously more like integration tests and covered part of the internals of GA, which I'm not really sure is necessary. Since GA is a 'soft' peer dependency, as long as GA behaves then we shouldn't care except that we call the interface correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants