chai相关内容
在Cypress测试中,我经常需要检查DOM元素中的文本是否等于预期的测试。但由于文本周围可能有一些空格,我不能简单地写成: cy.get('.cell') .should('have.text', 'Hello') 相反,我必须写: cy.get('.cell') .then($cell => $cell.text().trim()) .should('eq', 'H
..
我正在编写一个单元测试来测试我的postgres模式。我使用的是node-pg、mocha、sinon和chai。 这是可行的-测试通过,没有问题: describe('When adding a user', ()=> { it('should reject since email is used somewhere else', (done)=> { pool.quer
..
我对Mocha和Chai完全陌生。我已经创建了一个函数来比较测试中的两个对象。 function compareExtremelyCompexObject (testedObject, trueObject); 如何编写使用compareExtremelyCompexObject函数断言测试的Mocha Chai规范? 我有这样的东西: it('should create a
..
我使用chai编写测试。以下仅是三个测试示例: (实际还有更多测试,请查看链接的epl) 文件:tests/2_functional-tests.js const chaiHttp = require('chai-http'); const chai = require('chai'); const assert = chai.assert; const app = requir
..
使用chai、mocha和sinon为Google Cloud函数编写简单单元测试时遇到问题,虽然我指的是Google unit testing reference doc但无法理解。 问题 我在运行单元测试时收到以下错误消息。 TypeError: response.status is not a function 为什么在调用函数时需要类型转换请求和响应对象?在Googl
..
我当前正在测试Node.js/tyescript应用程序。 我的函数应返回对象数组。 这些对象的类型应为: type myType = { title: string; description: string; level: number; categorie: string; name: string; }; 以下代码不起作用 const ach:
..
我们有一个简单的等待方法,它利用节点应用程序中的承诺 exports.wait = (timeout) => { return new Promise((resolve) => { setTimeout(() => { resolve() }, timeout) }); }; 我们尝试使用sinon和chai测试此行为。 我们设法使用Chai-a
..
我怎样才能正确投掷?对于同一个函数,抛出和不抛都会通过测试 jsfiddle上也有代码,https://jsfiddle.net/8t5bf261/ class Person { constructor(age) { if (Object.prototype.toString.call(age) !== '[object Number]') throw 'NOT A N
..
我需要测试此函数: //user.js function getUser(req, res, next){ helper.get_user(param1, param2, (err, file) => { if (err) return next(err); } 这是我的测试函数: it ("failed - helper.get_u
..
我必须使用Mocha和Chai测试测试端点的响应。下面是相同的代码: async function getData (userId) { let response; let interval = setInterval(async () => { response = await superagent.get("localhost:30
..
我需要检查Div标记的文本,并确保它显示的文本是否正确 以下是HTML代码: 以下是我为断言内容而编写的步骤定义 Given(/^offer summary section should display "([^"]*)" amount against "([^"]*)"$/, (charge, labelText) => { const parentElemen
..
我正在尝试为我的 hubot 代码设置一个简单的单元测试,但我没有收到回复.我已将其简化为: test.coffee: Helper = require('hubot-test-helper')柴 = 需要“柴"期望 = chai.expecthelper = new Helper('../hubot-scripts/something.coffee')描述“PING",->之前 ->@r
..
尝试使用 Mocha/Chai 测试一些引发异常的代码,但没有运气,这是我尝试测试的简单代码: 类 window.VisualizationsManager测试:->抛出(新错误'哦不') 这是我的测试: 描述'VisualizationsManager',->它'不允许构建新实例',->manager = new window.VisualizationsManagerchai.expec
..
..
我有以下示例测试: import { assert } from 'chai'功能明星战争电影(){获取('http://swapi.co/api/films/').then((res) => {返回 res.json()}).then((res) => res.count)}describe('获取星球大战电影', () => {it('应该得到 7', () =>{assert.equal(
..
我在基于 Angular 的网站中有一个设置可以打开和关闭下拉菜单.如果它关闭,则它不会显示在主页上. 使用量角器,我需要检查开关关闭时是否不存在此元素.但是,我不应该陷入 Element Not Found Error,因为它是一组测试中的一个.我该怎么做? 我已经尝试过: expect($$('.switch').count()).to.equal(0).and.notify(n
..
所以我一直试图弄清楚如何根据 find All 元素的数量单击按钮 x 次.这意味着如果有 3 个元素由相同的类名找到,那么我们循环 3 次,应该点击按钮 3 次. 我做过这样的事情: (新的更新,检查底部的编辑帖子) 通常 element.all(by.className('btn btn-remove btn-outlined')).getText() 是 3 但可以更改为
..
如果我的方案失败,则不会生成 JSON 报告.但是对于通行证场景,我可以看到 JSON 报告. 请在下面找到我的配置文件. 在评论提示控制台中我可以看到失败消息: W/launcher - 忽略未捕获的错误 AssertionError:预期 false 等于 true E/launcher - BUG:启动器退出,剩余 1 个任务 解决方案 你可以使用钩子保存报告
..
我对 cucumberjs 有疑问.我找不到方法来确保具有给定选择器的元素被呈现到 DOM 中.我正在使用cucumberjs 与柴.https://github.com/cucumber/cucumber-jsisPresent 返回对象 - 无论元素是否存在.所以问题是如何检查元素是否存在于 DOM 中. 我将编辑问题以分享一个经验教训.我阅读了文档还要感谢 Nathan Thompso
..
所以,我正在测试一个依赖于事件发射器的组件.为此,我想出了一个使用 Promises with Mocha+Chai 的解决方案: it('should transition with the right event', (done) => {const cFSM = new CharacterFSM({},emitter, transitions);让超时=空;让解决=假;新承诺((解决,拒绝
..