Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

karma-static

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Issues
File Explorer

Advanced tools

karma-static

Serve a directory of static files on the Karma server.

    1.0.1latest
    npm

Version published
Maintainers
1
Weekly downloads
705
decreased by-40.15%

Weekly downloads

Readme

Source

karma-static

Serve a directory of static files on the Karma server.

This middleware can be used to prevent 404s on files not normally served by Karma. For instance, application components under test may load image files via <img> elements.

This middleware will probably be easier to use than specifying files patterns, and trying to work around the /base/ prefix added to all asset paths.

Install

Add it to your project:

npm i -D karma-static

Configure

Say that your project directory structure looks like this:

project/ ├── public/ │ ├── tests.js │ ├── icon.png └── karma.conf.js

Configure Karma to use the middleware:

var path = require('path'); module.exports = function (config) { config.set({ files: ['public/tests.js'], middleware: ['static'], static: { path: path.join(__dirname, 'public') } }); };

Now files in the public directory like icon.png will be served by the web server, and will no longer throw 404s when requested by components in tests.js.

License

MIT

FAQs

Last updated on 12 Nov 2017

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc