Skip to content

coreyferguson/karma-express-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Karma framework for running an extendable express application.

Resources

Stars

Watchers

Forks

Packages

No packages published