ES6单元测试,无需编译 [英] ES6 unit testing without compilation

查看:65
本文介绍了ES6单元测试,无需编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到通过Gulp直接在ES6代码上运行的Mocha或任何其他单元测试框架的任何示例. (没有Babel,Webpack等)

I'm not able to find any examples of Mocha or any other unit test framework running directly on ES6 code via Gulp. (No Babel, Webpack, etc.)

我已经跟踪了一个在ES6代码的浏览器中运行的Mocha(经过一些修改)的示例,但是它不是自动化的.

I've tracked down one example of Mocha (with some modification) running in a browser on ES6 code, but it was not automated.

有人在直接测试ES6代码吗?

Is anyone testing ES6 code directly yet?

(我知道这不是SO问题的正确"格式,但我现在处于我从哪里开始"阶段.)

(I understand this isn't the 'proper' format of an SO question, but I'm in the 'where do I start' phase here.)

推荐答案

Mocha在Node.js中运行测试,因此您可以使用和测试该节点中实现的任何es6功能.查看您的节点版本支持的功能:

Mocha runs tests in Node.js, therefore you can use and test any es6 feature which is implemented in the node. Check out supported features for your node version:

https://node.green/

在最新节点中,您将获得对ES2015的良好支持.

In the latest node you will get pretty good support for ES2015.

如果要使用ES6模块,它仍然是实验性功能,可以通过标志启用(自2018年起): https://nodejs.org/api/esm.html#esm_ecmascript_modules

If you want to use ES6 modules, it still experimental feature and it can be enabled by flag (as of 2018): https://nodejs.org/api/esm.html#esm_ecmascript_modules

这篇关于ES6单元测试,无需编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆