我正在尝试为我的反应应用程序编写一些测试。
当测试正确时,我会在控制台中得到这个。
0 passing (0ms)
Run Code Online (Sandbox Code Playgroud)
测试文件appTest.test.js
var expect = require('chai').expect
, foo = 'bar'
, beverages = { tea: [ 'chai', 'matcha', 'oolong' ] };
expect(foo).to.be.a('string');
expect(foo).to.equal('bar');
expect(foo).to.have.lengthOf(3);
expect(beverages).to.have.property('tea').with.lengthOf(3);
Run Code Online (Sandbox Code Playgroud)
包.json
"test": "NODE_ENV=test mocha --require @babel/register --require ./test/*.test.js --watch",
Run Code Online (Sandbox Code Playgroud)
有趣的是,如果我给出了错误的期望,它就会失败,因此它会收到文件
我得到了一个简单的HomeController.class:
package com.example.tacos;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HomeController {
@GetMapping("/")
public String home() {
return "home";
}
}
Run Code Online (Sandbox Code Playgroud)
我也有一个模板叫做 home.html
<!DOCTYPE HTML>
<head>
<title>Getting Started: Serving Web Content</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p>Hey</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
无论如何,我在浏览器中得到 404,IDE 告诉我无法解析 MVC“视图”,正如您在屏幕上看到的那样
chai ×1
mocha.js ×1
node.js ×1
reactjs ×1
spring ×1
spring-boot ×1
spring-mvc ×1
testing ×1
thymeleaf ×1