
Test
测试
灵谷
Im just a landlubber in the ocean of IT
展开
-
npm: cross-env是做什么的?
最主要的作用:解决windows环境中在script中设置环境变量的问题。如:NODE_ENV=test mocha原创 2021-07-05 12:01:45 · 345 阅读 · 0 评论 -
jsdom:如何执行script
默认情况下,jsdom不会执行脚本。需要配置:runScripts:“dangerously”import JSDOM from 'jsdom';const dom = new JSDOM(`<body> <script>document.body.appendChild(document.createElement("hr"));</script></body>`, { runScripts: "dangerously" });只有确原创 2021-07-02 15:51:07 · 975 阅读 · 0 评论 -
mocha: SecurityError: localStorage is not available for opaque origins
opaque: 不透明的很多包底层都是依赖jsdom的。只需要在配置jsdom的属性上设置好url就能解决localstorage的问题。如:jsdom-globaljsdomGlobal(htmlString, { url: "http://localhost"})mocha-jsdomjsdomMocha({ html: '', src: '', url: "http://localhost"})jsdomjsdom(htmlString, { url: "http://原创 2021-07-02 15:35:13 · 1397 阅读 · 0 评论 -
jest:入门笔记
1. APIdescribe: 定义一组测试test: 定义一项测试expect: 内置的断言API2. hooksafterAllafterEachbeforeAllbeforeEach原创 2021-06-30 11:20:57 · 88 阅读 · 0 评论 -
mocha:入门笔记
mocha命令行参数mocha [debug] [options] [files]1. options# 查看Mocha的所有命令行参数--help, -h# 用来指定测试报告的格式,默认是 spec 格式.--reporter, -Rmocha# 等同于mocha --reporter spec# 获得所有内置的报告格式--reporters# 第三方报告格式:mochawesome, 可以生成漂亮的HTML格式的报告mocha --reporter mochawesome原创 2021-06-25 17:43:13 · 540 阅读 · 0 评论