mocha.js

Protractor - Check if a radio-button is checked or not

点点圈 提交于 2021-02-11 04:49:06
问题 So I have this problem where I run a protractor/selenium test and sometimes a radio-button is already checked during the test and sometimes its not. etc: <div id="TRUCK" class="radio-item checked" data-gtm="truck"> or <div id="TRUCK" class="radio-item" data-gtm="deliveryOpt-truck"> where you can see the class sometimes have the "checked" init and sometimes not. What I am trying to do solve is that I want to make a function that clicks IF the radio-button is not checked and if its already

How do I pass value from beforeEach() to test? Mocha/Chai

孤街醉人 提交于 2021-02-11 02:49:33
问题 How do I pass the dom object, from my beforeEach() function, to my tests? For example: describe('2) Key DOM elements exist', function() { beforeEach(function(done){ JSDOM.fromURL('http://localhost:3000/', ).then(dom => { this.hello = dom; }); done(); }); it('a) Header element is present', function() { console.log(hello); const header = dom.window.document.getElementById('header'); expect(header).to.exist; }) }); 回答1: The issue is that this is not bound to the callback function passed to

How do I pass value from beforeEach() to test? Mocha/Chai

时光怂恿深爱的人放手 提交于 2021-02-11 02:48:54
问题 How do I pass the dom object, from my beforeEach() function, to my tests? For example: describe('2) Key DOM elements exist', function() { beforeEach(function(done){ JSDOM.fromURL('http://localhost:3000/', ).then(dom => { this.hello = dom; }); done(); }); it('a) Header element is present', function() { console.log(hello); const header = dom.window.document.getElementById('header'); expect(header).to.exist; }) }); 回答1: The issue is that this is not bound to the callback function passed to

How do I pass value from beforeEach() to test? Mocha/Chai

依然范特西╮ 提交于 2021-02-11 02:48:19
问题 How do I pass the dom object, from my beforeEach() function, to my tests? For example: describe('2) Key DOM elements exist', function() { beforeEach(function(done){ JSDOM.fromURL('http://localhost:3000/', ).then(dom => { this.hello = dom; }); done(); }); it('a) Header element is present', function() { console.log(hello); const header = dom.window.document.getElementById('header'); expect(header).to.exist; }) }); 回答1: The issue is that this is not bound to the callback function passed to

Keep MongoDB connection open while running tests using mocha framework

天涯浪子 提交于 2021-02-10 22:52:30
问题 I'm using something akin to How to properly reuse connection to Mongodb across NodeJs application and modules to keep my mongoDB Connection open. This requires all the code to go into a MongoDB.connectDB(async (err) => {...} Block. How would I use this when writing Tests with Mocha. Do I have to use a separate Connection for every test? Like this? const MongoDB = require('../src/mongoUtil') // providing access to the mongo database var events = require('../src/events') // containing all my

Keep MongoDB connection open while running tests using mocha framework

寵の児 提交于 2021-02-10 22:52:22
问题 I'm using something akin to How to properly reuse connection to Mongodb across NodeJs application and modules to keep my mongoDB Connection open. This requires all the code to go into a MongoDB.connectDB(async (err) => {...} Block. How would I use this when writing Tests with Mocha. Do I have to use a separate Connection for every test? Like this? const MongoDB = require('../src/mongoUtil') // providing access to the mongo database var events = require('../src/events') // containing all my

Why does running npm test result in: '.' is not recognized as an internal or external command, operable program or batch file.?

泪湿孤枕 提交于 2021-02-07 09:20:21
问题 I have the following installed: Windows 10 Git bash (mingw64) Node.js v8.7.0 npm version 5.4.2 Packages: chai 4.4.1 mocha 3.5.0 I have a sample mocha test that will always pass when it actually runs. The command I'm running in my shell: npm test Output: ./node_modules/mocha/bin/_mocha '.' is not recognized as an internal or external command, operable program or batch file. npm ERR! Test failed. See above for more details. For some reason I'm able to run this command directly: ./node_modules

Why does running npm test result in: '.' is not recognized as an internal or external command, operable program or batch file.?

ぐ巨炮叔叔 提交于 2021-02-07 09:17:56
问题 I have the following installed: Windows 10 Git bash (mingw64) Node.js v8.7.0 npm version 5.4.2 Packages: chai 4.4.1 mocha 3.5.0 I have a sample mocha test that will always pass when it actually runs. The command I'm running in my shell: npm test Output: ./node_modules/mocha/bin/_mocha '.' is not recognized as an internal or external command, operable program or batch file. npm ERR! Test failed. See above for more details. For some reason I'm able to run this command directly: ./node_modules

Using mocha for controller in functional test with RSPEC

[亡魂溺海] 提交于 2021-01-29 17:55:15
问题 I'm doing some tests here using Rspec and I would like to assure that the controller is calling the log method in some actions. I'm also using mocha. I would like something like this: it "update action should redirect when model is valid" do Tag.any_instance.stubs(:valid?).returns(true) put :update, :id => Tag.first controller.expects(:add_team_log).at_least_once response.should redirect_to(edit_admin_tag_url(assigns[:tag])) end is there something to use as the 'controller' variable? I tried

initClient Nightwatch - TypeError: Cannot read property 'verbose' of null

别说谁变了你拦得住时间么 提交于 2021-01-29 14:51:05
问题 I'm seeing the same error with below code. Is this a actual bug in initClient()? Any help is appreciated, thanks! async 'mydemo'(browser){ var nightwatch = require('../node_modules/nightwatch'); var config = require('../nightwatch.json'); console.log(config); var client = nightwatch.initClient(config.test_settings.default); var browserObj = client.api(); const homePage = browserObj.page.homepage(); homePage.navigate(); let result = await homePage.api.elements('css selector', 'div.flex.mt-4.v