
Node自动化测试
搭建node自动化项目
LetsStudy
The growth of age will not be a hindrance to study.
展开
-
6.4 node-xlsx
node-xlsx原创 2023-03-03 10:31:30 · 223 阅读 · 0 评论 -
6.3 nodejs自动化测试设计思路3—动态加载
nodejs自动化,动态加载原创 2023-02-08 15:48:54 · 323 阅读 · 0 评论 -
6.2 chokidar监测文件变化
chokidar监测文件变化原创 2023-01-09 16:33:42 · 243 阅读 · 0 评论 -
6.1 http-server
http-server原创 2022-12-01 16:45:48 · 222 阅读 · 0 评论 -
6.0 生成txt、doc文件
nodejs生成doc、txt文件原创 2022-11-09 16:50:38 · 295 阅读 · 0 评论 -
5.9 mysql插入文件
mysql插入文件原创 2023-02-16 09:38:52 · 227 阅读 · 0 评论 -
5.8 node将pdf转图片
文档地址:https://www.npmjs.com/package/pdf2pic转载 2022-09-27 17:54:37 · 801 阅读 · 0 评论 -
5.7 node解析pdf
文档地址:https://www.npmjs.com/package/pdf2json转载 2022-09-27 17:53:22 · 157 阅读 · 0 评论 -
5.6 node使用rest服务操作hbase
node通过hbase的rest服务,对hbase进行数据处理原创 2022-09-26 14:13:29 · 583 阅读 · 0 评论 -
5.5 memlab内存泄漏检测
文档地址:How memlab Works | memlab转载 2022-09-22 17:42:54 · 293 阅读 · 0 评论 -
5.4 rxjs
文档地址:https://cn.rx.js.org/转载 2022-09-22 17:40:55 · 101 阅读 · 0 评论 -
5.3 node操作neo4j图数据库
node操作neo4j数据库原创 2022-09-22 17:38:35 · 708 阅读 · 0 评论 -
5.2 thrift2连接hbase
thrift2原创 2022-09-21 14:48:58 · 930 阅读 · 0 评论 -
5.1 node连接hbase的其他方式
node通过rest方式连接hbase原创 2022-09-21 10:30:29 · 565 阅读 · 0 评论 -
5.0 nodejs通过thrift连接hbase
python或者node通过thrift连接hbase原创 2022-09-20 14:24:46 · 714 阅读 · 0 评论 -
4.9 nodejs操作多种数据库
node操作多种数据库原创 2022-09-13 14:44:59 · 1020 阅读 · 0 评论 -
4.8 playwright实现页面及接口的自动化
【代码】4.8 playwright实现页面及接口的自动化。原创 2022-08-23 14:32:00 · 1000 阅读 · 0 评论 -
4.7 minio下载文件代码优化
优化nodejs下载minio文件原创 2022-08-10 16:58:54 · 887 阅读 · 0 评论 -
4.6 从minio上下载文件
nodejs操作minio原创 2022-07-06 16:15:53 · 2857 阅读 · 0 评论 -
4.5 nodejs自动化测试设计思路2
自动化代码设计原创 2022-07-18 15:37:03 · 347 阅读 · 0 评论 -
4.4 nodejs自动化测试代码设计思路
自动化测试代码设计及实现原创 2022-06-10 14:54:53 · 532 阅读 · 0 评论 -
4.3 worker_thread从postgres取数据并发
1、数据库配置config/config.jsexports.config = { options:{ host: 'postgres-testdata.lan', port: 5432, user: 'kear', database: 'test', password: '123123', }}2、数据库连接并返回数据api:https://node-postgres.com/api/poo原创 2022-05-10 15:19:24 · 245 阅读 · 0 评论 -
4.2 使用常用的汉字生成随机文本
1、character.jsmodule.exports = "\u7684\u4e00\u4e86\u662f\u6211\u4e0d\u5728\u4eba\u4eec\u6709\u6765\u4ed6\u8fd9\u4e0a\u7740\u4e2a\u5730\u5230\u5927\u91cc\u8bf4\u5c31\u53bb\u5b50\u5f97" + "\u4e5f\u548c\u90a3\u8981\u4e0b\u770b\u5929\u65f6\u8fc7\u51fa\u原创 2022-03-18 15:47:31 · 3844 阅读 · 0 评论 -
4.1 自定义多线程执行jest测试脚本
jest本身就是多进程执行文件,本次只是在学习工作线程的一次尝试1、准备两个测试文件test.jsconst assert = require('assert')describe('test',function (){ it('should ', function () { assert.ok('1') });})hello.test.jsconst assert = require('assert')describe('',function原创 2022-01-27 17:01:06 · 1089 阅读 · 0 评论 -
4.0 复制文件目录结构及文件本身
原本将自动化测试在中,失败的文件复制到一个failed文件夹里,但是发现错误文件太多的话,不太好区分这些文件原本属于哪个目录结构,毕竟在原文件的目录结构里,对这些文件进行了区分,所以修改代码,连同原有的目录结构一快复制过去一、新增一个方法/**下述方法主要对目录结构做一个简单的提取及拼接根据实际情况,去除掉文件名和前面最前面的两层目录并且循环去创建目录,由于dir默认值是"\\",所有dirpath后面不需要带"\\"如copyDir("D://","D://test/new/project原创 2021-12-13 14:39:19 · 495 阅读 · 0 评论 -
3.9 jest自定义失败重跑
由于最近做formData格式的请求,需要对一大批文件做接口自动化的测试,当某些文件因为超时、文件本身、程序本身等原因造成自动化脚本中的部分用例失败时,我们就需要把这些文件单独来出来进行甄别及修改,以便再次运行脚本的时候,可以单独运行产生错误的文件,jest本身的bail参数显然不能满足当前需求。一、封装新建目录及复制文件的方法const fs = require('fs')const path = require('path')function createDir(dirpath, fil原创 2021-12-07 17:38:59 · 502 阅读 · 0 评论 -
3.8 node处理formData请求
一、工作中需要发送formData请求,循环发送某个目录下的所有文件,再通过其他接口获取结果,所以先要提取文件//parse_file.jsconst fs = require('fs');const path = require('path');var temp = []exports.parse_file = function parse_file(dir_path) { let p = path.join(dir_path); let stat =原创 2021-12-01 17:35:51 · 3159 阅读 · 0 评论 -
3.7 jest的前置与后置执行
jest提供了几个配置,可以在测试文件之前执行一、globalSetup/globalTeardown一般情况下,globalSetup中导出的变量,只能在globalTeardown中引用,如果要在测试文件中引用,需要在使用命令行参数来执行jest --runInBand如果是用gulp调用的jest则直接可以在config中添加,如const gulp = require('gulp');const jest = require('gulp-jest').default;co原创 2021-07-27 15:32:25 · 1026 阅读 · 0 评论 -
3.6 jest使用jest-html-reporters
官方地址:https://github.com/roughsoft/jest-html-reporters注意,是jest-html-reporters,不是jest-html-reporter一、直接安装npm install jest-html-reporters二、在jest.config.js中添加配置文件const moment = require('moment');const date = moment(new Date()).format('YYYY-MM-DD-H原创 2021-07-27 08:59:55 · 1284 阅读 · 0 评论 -
3.5 cheerio文档
中文官方文档https://github.com/cheeriojs/cheerio/wiki/Chinese-README转载 2021-07-01 16:50:15 · 316 阅读 · 0 评论 -
3.4 jest使用pug
项目中会有多份jest的报告,需要对报告进行管理思路上用使用pug模板生成html,读取报告目录里的html文件后,进行排序,根据排序,使用cheerio解析html,然后进行数据组装,然后使用gulp-pug进行参数传递,需要用到的包fs、gulp-pug、cheerio一、编写pug模板<!DOCTYPE html>head h2 TestRunner ResultList meta(http-equiv="Content-Type" content="tex原创 2021-07-01 16:38:06 · 237 阅读 · 0 评论 -
3.3 mocha转jest
一、jest和mocha之间的机制有着显著的不同,jest具体使用可以看官方文档,这里只简单说明下两种框架的不同点1、jest没有this指向,在mocha中可以运行this,如this.skip()等,但是jest中的跳过只能是使用it.skip(),这种形式。2、jest是多进程的,全局处理globalSetup和globalTeardown中赋值的变量,是不能传递出去的。如果要传递出去,需要将并行改为串行,添加runInBand参数即可 testEnvironment: "原创 2021-06-28 11:01:51 · 456 阅读 · 0 评论 -
3.2 node-rsa解密
一、前端使用的是jsencrypt,使用的是pkcs1加密方案如果用node实现这个加密过程,就需要使用setOptions方法进行设置const NodeRSA = require('node-rsa');exports.encrypt = function (pkey,data){ let buff = Buffer.from(data); let key = new NodeRSA(pkey); key.setOptions({encryptionScheme: 'pk原创 2021-06-16 15:04:36 · 1338 阅读 · 1 评论 -
3.1 mocha使用allure报告
一、安装allure-commandlinenpm install allure-commandline 二、安装reporternpm install mocha-allure-reporter三、执行测试mocha src/api/list --reporter mocha-allure-reporter四、生成测试报告allure generate allure-results --clean -o allure-report && allure open allu原创 2021-06-15 10:28:22 · 513 阅读 · 0 评论 -
3.0 node设置等待时间
一、js设置等待时间exports.wait = function (ms) { return new Promise(resolve =>setTimeout(() =>resolve(), ms)); };原创 2021-06-11 08:41:10 · 752 阅读 · 0 评论 -
2.9 mochawesome改变测试报告目录及名称
一、gulpfile.js中可以修改gulp.task('website', function() { return gulp.src(['src/api/serviceflow/website_workflow.js'], { read: false }) .pipe(mocha({ reporter: 'mochawesome', reportDir: 'test', reporterOptions:原创 2021-06-11 08:38:59 · 287 阅读 · 0 评论 -
2.8 接口间的参数传递
一、mocha自动化可以通过this.ctx来传递也可以通过外层的变量来传递示例/** * 正则接口用例 * @type {AxiosStatic | {CancelTokenSource: CancelTokenSource, CancelStatic: CancelStatic, AxiosProxyConfig: AxiosProxyConfig, Canceler: Canceler, AxiosStatic: AxiosStatic, AxiosRequestConfig: Ax原创 2021-05-31 17:43:45 · 345 阅读 · 2 评论 -
2.7 list接口代码示例
一、接口list示例/** * 首页接口用例 * @type {AxiosStatic | {CancelTokenSource: CancelTokenSource, CancelStatic: CancelStatic, AxiosProxyConfig: AxiosProxyConfig, Canceler: Canceler, AxiosStatic: AxiosStatic, AxiosRequestConfig: AxiosRequestConfig, AxiosTransforme.原创 2021-05-31 17:37:48 · 170 阅读 · 0 评论 -
2.6 随机数配置
一、在自动化脚本中,会对很多入参进行参数化配置有的参数使用随机值,有的参数可能需要使用给定列表中的某一个值新建一个js,exports各种随机值const Mock = require('mockjs');const moment = require('moment');exports.randomKey = Mock.mock({'number|0-1': 1}).number;exports.randomName = Mock.mock({ 'array|1': [原创 2021-05-31 17:24:57 · 278 阅读 · 0 评论 -
2.5 js格式化时间库
官方文档:http://momentjs.cn/原创 2021-05-28 16:39:20 · 230 阅读 · 0 评论