chai

Set accepted CA list and ignore SSL errors with chai-http

核能气质少年 提交于 2021-01-02 08:22:37
问题 I'm trying to write unit tests for my node code with chai/chai-http. Everything was working fine until I switched my server to an HTTPS server, but because my certificate is signed by an internal company root and the common name of the certificate I'm using doesn't match localhost, chai is throwing an error on my request. I'd like to do the following: Ignore SSL errors related to domain name verification. Set the list of CAs to check against. If this cannot be done, I'd be fine with just

Is there a way to assert that a route has not been called in Cypress?

走远了吗. 提交于 2021-01-02 05:04:08
问题 I am trying to assert that a route has not been called in Cypress. I thoroughly looked through the documentation and have found nothing. I am trying to do something like this: cy.get('@myRouteAlias').should('have.not.been.called'); I am currently working around this by asserting that the successful request toast message is not being displayed but it is a flimsy solution. Any ideas? 回答1: It is very difficult to test a situation where an action has not occured. With this type of assertion, you

How do I dynamically generate Mocha tests in a describe()'s before() block?

我与影子孤独终老i 提交于 2020-12-30 09:16:41
问题 I am creating a mocha test suite that is testing a command line utility that our nwjs app is calling which takes files and produces an output json file. I have thousands of combinations of input files and my tests (it()s) that I want to generate depend on the contents of the json output from the cmdline utility. Mocha seems to want to require me to create all of the it()s upfront, but that means these scripts need to be run upfront and the json output captured. I was hoping to do: 'use strict

How do I dynamically generate Mocha tests in a describe()'s before() block?

和自甴很熟 提交于 2020-12-30 09:14:58
问题 I am creating a mocha test suite that is testing a command line utility that our nwjs app is calling which takes files and produces an output json file. I have thousands of combinations of input files and my tests (it()s) that I want to generate depend on the contents of the json output from the cmdline utility. Mocha seems to want to require me to create all of the it()s upfront, but that means these scripts need to be run upfront and the json output captured. I was hoping to do: 'use strict

How do I dynamically generate Mocha tests in a describe()'s before() block?

↘锁芯ラ 提交于 2020-12-30 09:14:50
问题 I am creating a mocha test suite that is testing a command line utility that our nwjs app is calling which takes files and produces an output json file. I have thousands of combinations of input files and my tests (it()s) that I want to generate depend on the contents of the json output from the cmdline utility. Mocha seems to want to require me to create all of the it()s upfront, but that means these scripts need to be run upfront and the json output captured. I was hoping to do: 'use strict

How do I dynamically generate Mocha tests in a describe()'s before() block?

点点圈 提交于 2020-12-30 09:06:03
问题 I am creating a mocha test suite that is testing a command line utility that our nwjs app is calling which takes files and produces an output json file. I have thousands of combinations of input files and my tests (it()s) that I want to generate depend on the contents of the json output from the cmdline utility. Mocha seems to want to require me to create all of the it()s upfront, but that means these scripts need to be run upfront and the json output captured. I was hoping to do: 'use strict

How to send array in JSON object for ChaiHttp Unit Testing?

不问归期 提交于 2020-12-15 05:20:33
问题 I have an API in node.js, where I can send payloads for multiple DeviceIds, to update their settings. For instance, a sample payload that I would send is: {"DeviceId":["1","2","3"],"Settings":[{"Key":"OnSwitch","Value":"true"}]} After sending it, I would say that the DeviceId 1,2,3 all will have updated their settings. This is working correctly and I've tested it locally in Postman. I now want to write a unit test to check the behaviour. My unit test is the following: context('POST With

Using Chai expect throw not catching promise rejection

痞子三分冷 提交于 2020-12-06 04:50:09
问题 I have searched all around how to solve this, but all solutions I tested don't work in my case. I have a function that returns a promise, which I'm trying to test using Mocha and Chai. I'm fuzzing the parameter so the function always returns: reject('Rejection reason') Here's the test I'm trying to run: describe('fuzzing tokenization with 1000 invalid values', () => { it('should throw an error - invalid value', async () => { for(var i=0; i <= 1000; i++){ var req = { body: { value: fuzzer

package.json 笔记

夙愿已清 提交于 2020-11-25 06:07:48
package.json 1、概述: 每个项目的根目录下面,一般都有一个 package.json 文件,定义了这个项目所需要的各种模块,以及项目的配置信息(比如 名称、版本、许可证等元数据 )。 npm install 命令根据这个配置文件,自动下载所需的模块,也就是配置项目所需的运行和开发环境。 package.json :>>>内部是json对象 { "name " : "xxx ", //name就是项目名称 "version " : "0.0.0 ", //version是版本(遵守“大版本.次要版本.小版本”的格式)。 } 完整的package.json { "name ": "Hello World ", "version ": "0.0.1 ", "author ": "张三 ", "description ": "第一个node.js程序 ", "keywords ":[ "node.js ", "javascript "], "repository ": { "type ": "git ", "url ": "https://path/to/url " }, "license ": "MIT ", "engines ": { "node ": "0.10.x "}, "bugs ":{ "url ": "http://path/to/bug ", "email