Can't test function in terminal


#1

I’m trying to do the javascript exercises from Fundamentals Part 4, but I can’t seem to test the function helloWorld() in my terminal. The function passes the test, but if I try to test the function helloWorld() which should output ‘Hello, World!’ it will just output ‘>’
What am I missing?

This is the code from helloWorld.js
const helloWorld = function() {
return ‘Hello, World!’
}

module.exports = helloWorld

This is the code from helloWorld.spec.js
const helloWorld = require(’./helloWorld’);

describe(‘Hello World’, function() {
it(‘says hello world’, function() {
expect(helloWorld()).toEqual(‘Hello, World!’);
});
});

This is from the terminal

kvnirvana@kvnirvana-eMachines-E525:~/javascript-exercises/helloWorld$ helloWorld()


#2

You can’t access the function directly in your terminal.

The test file (helloWorld.spec.js) imports the function, which is why it can read it and evaluate it based on the test, and can output a result. Your terminal is not itself importing this function.