karma-express-server

0.1.4 • Public • Published

karmaExpressServer

Summary

Runs a customizable expressjs application for karma tests.

Usage

Install

npm install --save-dev karma-express-server

Configure

Add framework and expressServer configuration to karma config:

module.exports = function(config) {
  config.set({
 
    // ...
 
    frameworks: [
      // ...
      'expressServer'
    ],
 
    // ...
 
    expressServer: {
 
      port: 9877, // different than karma's port
 
      // custom extensions go here
      extensions: [
        // for example:
        function(
          app, // express app
          logger // karma logger
        ) {
          app.get('/heartbeat', (req, res) => {
            res.sendStatus(200);
          });
        }
      ]
 
    }
 
  });
};

SSL

Self-signed certificates can be generated with nodejs-self-signed-certificate-example.

// ...
 
expressServer: {
 
  // ...
 
  protocol: 'https',
  httpsServerOptions: {
    key: fs.readFileSync('path/to/my-server.key.pem'),
    cert: fs.readFileSync('path/to/my-server.crt.pem')
  }
 
}
 
// ...

More Configuration

All Config properties are documented in the API Documentation.

Contribution

See Contribution documentation for build, test and publish details.

Readme

Keywords

Package Sidebar

Install

npm i karma-express-server

Weekly Downloads

10

Version

0.1.4

License

MIT

Last publish

Collaborators

  • coreyferguson