jsdom

NutUI 3.0 中单元测试的探索和实践

无人久伴 提交于 2020-03-23 20:36:34
3 月,跳不动了?>>> 众所周知,单元测试功能,是组件库开发中必不可少的一部分,负责进行检查和验证,保证了组件的合理性和规范性。本文主要讲的就是单元测试在 NUTUI 组件库 中的探索实践,我们将从如何编写单元测试、持续集成服务、Coveralls 自动测试代码覆盖率三方面进行阐述。如图所示: 如果你对这些内容感兴趣,就和我一起来看一下吧! 单元测试配置 在进入单元测试配置正文之前,我们先来了解下面两个问题。 单元测试是什么? 为什么需要单元测试? 单元测试是什么? 单元测试(unit testing),可以对软件中的最小可测试单元进行检查和验证,是软件开发中重要的一部分。它使得添加新功能和追踪问题更加容易。 为什么需要单元测试? 单元测试在开发的时候很有用,即能帮助开发者思考如何设计一个组件,也能够重构一个现有组件。每次代码发生变化的时候它们都会被运行。有了单元测试,我们可以自信的交付自己的代码,而没有任何的后顾之忧。 组件的单元测试有以下等优点: 提供描述组件行为的文档 减少调试时间,节省手动测试的时间 减少研发新特性时产生的 bug,测出功能的隐藏 bug 减少和快速定位 bug 促进重构,保证代码重构的安全性 如何编写单元测试? 我们既是单元测试的受益者,同时也是开发者,接下来我们进入正题,来聊一聊,如何在 vue 组件库中,加入单元测试。

NutUI 3.0 中单元测试的探索和实践

懵懂的女人 提交于 2020-03-20 22:58:48
3 月,跳不动了?>>> 众所周知,单元测试功能,是组件库开发中必不可少的一部分,负责进行检查和验证,保证了组件的合理性和规范性。本文主要讲的就是单元测试在 NUTUI 组件库 中的探索实践,我们将从如何编写单元测试、持续集成服务、Coveralls 自动测试代码覆盖率三方面进行阐述。如图所示: 如果你对这些内容感兴趣,就和我一起来看一下吧! 单元测试配置 在进入单元测试配置正文之前,我们先来了解下面两个问题。 单元测试是什么? 为什么需要单元测试? 单元测试是什么? 单元测试(unit testing),可以对软件中的最小可测试单元进行检查和验证,是软件开发中重要的一部分。它使得添加新功能和追踪问题更加容易。 为什么需要单元测试? 单元测试在开发的时候很有用,即能帮助开发者思考如何设计一个组件,也能够重构一个现有组件。每次代码发生变化的时候它们都会被运行。有了单元测试,我们可以自信的交付自己的代码,而没有任何的后顾之忧。 组件的单元测试有以下等优点: 提供描述组件行为的文档 减少调试时间,节省手动测试的时间 减少研发新特性时产生的 bug,测出功能的隐藏 bug 减少和快速定位 bug 促进重构,保证代码重构的安全性 如何编写单元测试? 我们既是单元测试的受益者,同时也是开发者,接下来我们进入正题,来聊一聊,如何在 vue 组件库中,加入单元测试。

Zombiejs jQuery nullTypeError 'compareDocumentPosition'

流过昼夜 提交于 2020-02-25 09:22:29
问题 Zombie: Cannot read property 'compareDocumentPosition' of null TypeError: Cannot read property 'compareDocumentPosition' of null This happens any time I try to load a page that includes jQuery using Zombiejs. This has happened to me on Debian & Windows, with a variety of different pages, using different versions of jQuery and with nothing else on the page. It seems to have something to do with the way jsDom evaluates jQuery before the page document is ready, but it's pretty far over my head.

Zombiejs jQuery nullTypeError 'compareDocumentPosition'

依然范特西╮ 提交于 2020-02-25 09:21:30
问题 Zombie: Cannot read property 'compareDocumentPosition' of null TypeError: Cannot read property 'compareDocumentPosition' of null This happens any time I try to load a page that includes jQuery using Zombiejs. This has happened to me on Debian & Windows, with a variety of different pages, using different versions of jQuery and with nothing else on the page. It seems to have something to do with the way jsDom evaluates jQuery before the page document is ready, but it's pretty far over my head.

disable CORS checking in jsdom on nodejs

纵然是瞬间 提交于 2020-01-04 21:30:57
问题 Is it possible to disable the CORS checking functionality in the jsdom node module? The CORS errors are particularly difficult to debug in my use case (clientside testing) and do not occur in the actual environment I am running the program. Perhaps some environmental variable we can set when initializing the object? e.g., window = new jsdom.JSDOM(``,{ cors : false, }).window; 回答1: As stated in this issue on JSDOM Github repository, JSDOM acts like a browser and the same-origin policy applies.

disable CORS checking in jsdom on nodejs

随声附和 提交于 2020-01-04 21:30:49
问题 Is it possible to disable the CORS checking functionality in the jsdom node module? The CORS errors are particularly difficult to debug in my use case (clientside testing) and do not occur in the actual environment I am running the program. Perhaps some environmental variable we can set when initializing the object? e.g., window = new jsdom.JSDOM(``,{ cors : false, }).window; 回答1: As stated in this issue on JSDOM Github repository, JSDOM acts like a browser and the same-origin policy applies.

Azure and Node.js and JSDOM scheduled task - opening a webpage with scripts

僤鯓⒐⒋嵵緔 提交于 2020-01-03 05:24:08
问题 I have an Azure website that has uses a thirty party script (DHTMLX Schedule library). I want to be able to render out a PDF and send it as an email as a weekly automated task. I have a C# MVC page that is using their .NET Scheduler to render the schedule and at the moment, when the page loads in a browser it essentially does everything I need. However I am trying to create this as a scheduled task in Azure. The page has a lot of JavaScript and CSS which renders out the schedule which gets

What is the difference between jsdom.env() and jsdom.jsdom?

雨燕双飞 提交于 2020-01-02 04:29:11
问题 I am still foggy about how to used jsdom. What is the difference between jsdom.env() and jsdom.jsdom? 回答1: The readme file explains that jsdom.env is built for ease of use, which is rare in the world of the DOM! Since the web has some absolutely horrible javascript on it, as of jsdom 0.2.0 jsdom.env will not process external resources (scripts, images, etc). If you want to process the javascript use one of the methods below (jsdom.jsdom or jsdom.jQueryify) 来源: https://stackoverflow.com

How do I return a value from a simple jsdom function?

一世执手 提交于 2020-01-01 05:39:25
问题 I'm using jsdom with jquery, and it's working just fine. However, I'm trying to modularize my code a bit so I don't repeat myself, so I made a basic function out of some jsdom code that takes in some html (DOM), tweaks it with jquery, and spits it back out. However, I'm unable to return my result and thus assign it to a calling var. I'm probably not returning in the right place, but I'm just not seeing the obvious if so. Could use a little help. Here's the code: function tweakIt(html_in){ var

Testing Typescript Generated Classes with node.js, Mocha and mocha-jsdom?

十年热恋 提交于 2019-12-25 08:36:40
问题 I would like to run unit tests from bash to test my Typescript generated Javascript classes using mocha and mocha-jsdom. I'm using mocha-jsdom because I want to emulate the dom in my tests but run unit tests from bash. I've seen a few examples where they use the frontend testing framework for mocha in a browser, but I haven't seen any where they are run from bash. It appears that I am unable to include the Javascript classes generated from Typescript in my mocha unit tests. var jsdom =