sinon-chrome | Testing chrome extensions with Node.js | Browser Plugin library
kandi X-RAY | sinon-chrome Summary
kandi X-RAY | sinon-chrome Summary
Testing chrome extensions with Node.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get a description
- Navigates to a new URL .
- Gets the value of a reference
- Get all fields
- Remove details from a description
- Set a url .
- Throw an error
sinon-chrome Key Features
sinon-chrome Examples and Code Snippets
const sinon = require('sinon')
const browser = require('sinon-chrome/extensions')
const I18nPlugin = require('sinon-chrome/plugins').I18nPlugin // I18n plugin constructor
const { assert } = require('chai')
const helpers = require('../src/h
Community Discussions
Trending Discussions on sinon-chrome
QUESTION
I am writing a test for a function MyFuntion
and that calls another function sendTouchEvent
that instantiates a TouchEvent.
ANSWER
Answered 2021-Aug-21 at 17:53I found out that the problem was the rewire
lib. For some reason, it was messing with the window's events. I remove it and change my code to be able to mock data
variable without rewire
QUESTION
I am working on a Google Chrome extension which is written in angular and I need to write unit tests for components that make use of the Chrome API. I found a library that I believe will do the job.
https://www.npmjs.com/package/sinon-chrome
However, I do not have enough experience with Angular to know how exactly to put the library into use. The usage section says that I need to require the value in a constant, but I have no idea how or where that would go. Does that go in the unit test? Does that go in the karma
file? What is the global.chrome
that is found in the examples.
The code for my unit test. It otherwise runs fine except for this chrome mock issue.
...ANSWER
Answered 2021-Feb-28 at 07:28I would suggest you simply to check existing examples.
Go to their github: https://github.com/acvetkov/sinon-chrome
On the right side you can see "Used by". Go there: https://github.com/acvetkov/sinon-chrome/network/dependents?package_id=UGFja2FnZS0xMzc4MTk5MA%3D%3D
Then go to repo by repo and search in the search bar for "sinon-chrome" (without quotes)
This should show you how others use the package, and, I hope, it brings light on your question.
QUESTION
I've written a unit test for the following code and stubbed the browser methods (read: web-extension API) using Sinon (more specifically: sinon-chrome, a dated but still functioning library for my use case).
...ANSWER
Answered 2020-Aug-11 at 20:57Turns out sinon-chrome, for whatever reason, needs to register the 'i18n' plugin during runtime and before tests are run.
Why this specific part of the web-extensions API is not implemented the same way all the other mocks are remains a mystery, but adding two lines fixed the problem and allowed the sinon stubs to work as expected:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sinon-chrome
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page