question typ: nodejs / webserver / html css

question typ: nodejs / webserver / html css

by Christian Gasde -
Number of replies: 2

Hi Richard,

I'm new to the coderunner questiontyp : nodejs.   :-)

I tried the following:

function myFunction() {
    const http = require('http');

    const port = process.env.PORT || 3000;

    http.createServer(function(request, response) {
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.end("Hello, World!\n");
    }).listen(port);

    console.log(`App is running... (port: ${port})`);
}

I got no error (screenshot) but of course on browser output.

Code example node.js
Is there any way to get a browser window running?

Why?

We want to use coderunner to write html & css tests for out students.

Is this approach ( node.js with a webserver in the background... html /css files )  a good one?
Or is there anyway a procedure to test  html & css knowledge  via coderunner?

Sorry for that basic questions! :-)

Best Regards from Coburg
Chris

In reply to Christian Gasde

Re: question typ: nodejs / webserver / html css

by Richard Lobb -
The short answer to your question is probably "no". 
 
Testing HTML/CSS is in general quite hard. What you would ideally like to know is whether the result rendered by the browser "looks right" and "behaves right" but these are very difficult to test and quantify.
 
There are web testing environments that run a headless browser on the server and test code using browser automation tools like Selenium but setting up such an environment in CodeRunner is a big job and probably not what you want anyway. 
 
There are a few threads on this topic already. Perhaps you can find something useful in there?
In reply to Christian Gasde

Re: question typ: nodejs / webserver / html css

by Christian Gasde -
Great!! I will check the related threads! Thanks again!!