Javascript Odin项目TDD解决方案
我在做奥丁项目。我现在正在学习TDD。我需要帮助通过“helloWorld”的第一次测试 JS文件:Javascript Odin项目TDD解决方案,javascript,tdd,Javascript,Tdd,我在做奥丁项目。我现在正在学习TDD。我需要帮助通过“helloWorld”的第一次测试 JS文件: const helloWorld = function() { return '' } module.exports = helloWorld .spec文件: const helloWorld = require('./helloWorld'); describe('Hello World', function() { it('says hello world', functio
const helloWorld = function() {
return ''
}
module.exports = helloWorld
.spec文件:
const helloWorld = require('./helloWorld');
describe('Hello World', function() {
it('says hello world', function() {
expect(helloWorld()).toEqual('Hello, World!');
});
});
测试未通过,因为函数在返回Hello,World!我进入JS文件,进行更改并保存
const helloWorld = function() {
return 'Hello, World!'
}
module.exports = helloWorld
我在终端中运行“jasmine helloWorld.spec.js”命令。终端返回以下消息:
Failures:
1) Hello World says hello world
Message:
Expected '' to equal 'Hello, World!'.
Stack:
Error: Expected '' to equal 'Hello, World!'.
请帮忙。你应该写你好,世界!而不是hello world。该函数对字符敏感。现在,您的函数返回一个空字符串,而不是让它返回您的测试所期望的字符串—“Hello,World!”: const helloWorld=函数{ 返回“你好,世界!” }