Category: Testing

0

Stubbing a class without invoking a constructor

You can create Stub instances using sinon.createStubInstance. const sinon = require(‘sinon’); const Foo = require(‘../Foo.js’); const fooStub = sinon.createStubInstance(Foo); fooStub.foo { bar() { returns ‘bar’; } } expect(fooStub.foo.bar()).to.equal(‘bar’);

0

Debug mocha using visual studio code

Add the following configuration in your launch.json { “name”: “Run mocha”, “type”: “node”, “request”: “launch”, “program”: “${workspaceRoot}/node_modules/mocha/bin/mocha”, “stopOnEntry”: false, “args”: [ “test/**/*.js”, “–inspect”, “–debug-brk”, “–no-timeouts” ], “cwd”: “${workspaceRoot}”, “runtimeExecutable”: null, “env”: { “NODE_ENV”: “testing”...

0

Automate chrome apps

Chrome apps written using webview are different than iFrames because webview is a separate process. With Selenium 2.20 it is possible to automate chrome apps written using webview. driver = webdriver.Chrome(desired_capabilities={‘chromeOptions’:{‘windowTypes’:[‘webview’]}}) driver.get(‘chrome://apps’) wait_for_new_window_to_appear() driver.switch_to.window(driver.window_handles[1])...

0

Cannot stub non-existent own property

The potential problem could be that sinon does not mock objects with dynamically-created methods through Object.prototype. To mitigate such problem, you can try the following : var sinon = require(‘sinon’); var sandbox = sinon.sandbox.create();...