-
Description Now the Test Cases can detect if you displayed the correct thing!
Code //// Created by RHB // Your code here const hello=()=>{ console.log("Hello, World!") }
Preloaded Code // Capture the console output let consoleOutput = []; const originalLog = console.log; const s = () => { console.log = (output) => consoleOutput.push(output); } const r = () => { // Restore console.log console.log = originalLog; }
Test Cases const {assert} = require("chai"); describe("Test Results", function() { it("does it print hello world", function() {s() // Run the user's function hello(); // Check if "Hello World" was logged const actual = consoleOutput.join('\n'); const expected = "Hello, World!";r() assert.equal(actual, expected); }); });
Output:
-
Code ## Created by RHB# Your code here[print(chr(i),end="") for i in [100, 108, 114, 111, 87, 32, 111, 108, 108, 101, 72][::-1]]- //// Created by RHB
- // Your code here
- const hello=()=>{
- console.log("Hello, World!")
- }
Preloaded Code - // Capture the console output
- let consoleOutput = [];
- const originalLog = console.log;
- const s = () => {
- console.log = (output) => consoleOutput.push(output);
- }
- const r = () => {
- // Restore console.log
- console.log = originalLog;
- }
Test Cases import codewars_test as test# TODO Write testsimport solution # or from solution import example- const {assert} = require("chai");
- describe("Test Results", function() {
- it("does it print hello world", function() {s()
# test.assert_equals(actual, expected, [optional] message)@test.describe("Test Results")def test_group():@test.it("does it print hello world")def test_case():test.expect(passed="Hello World", message=None, allow_raise=False)- // Run the user's function
- hello();
- // Check if "Hello World" was logged
- const actual = consoleOutput.join('\n');
- const expected = "Hello, World!";r()
- assert.equal(actual, expected);
- });
- });
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}