karma-static
Advanced tools
Serve a directory of static files on the Karma server.
Weekly downloads
Readme
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.
Add it to your project:
npm i -D karma-static
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
.
MIT
FAQs
Serve a directory of static files on the Karma server.
The npm package karma-static receives a total of 512 weekly downloads. As such, karma-static popularity was classified as not popular.
We found that karma-static demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.