Giter Site home page Giter Site logo

jhendess / karma-preprocessor-pullscripts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hagis/karma-preprocessor-pullscripts

1.0 2.0 1.0 7 KB

Karma preprocessor that reads JS files from <script> tags from html

License: Other

JavaScript 100.00%

karma-preprocessor-pullscripts's Introduction

Karma-preprocessor-pullscripts: read Javascript referred to by your project's html

Instead of duplicating all your app's Javascript references in your Karma config, just refer to your HTML files, test files and mocks.

Also supports reading external Javascript files via HTTP.

This preprocessor lets you load your project's HTML files, from which the files denoted by the src field in the <script> files are read or downloaded and included in the test suites.

This is handy for running your tests againts your dist package.

Pros:

  1. Your project's html files are used, meaning you are guaranteed that there is consistency between test and live resources
  2. You do not need to manage local copies of resources using, e.g. bower

Cons for case 2:

  1. Tests require Internet connectivity
  2. Downloads on each test iteration

Installation

$ npm install karma-preprocessor-pullscripts

Configuration

First, include html files in the files section of your karma.conf.js. These will be processed in order.

files: [
    './path/to/file1.html',
    './path/to/file2.html',

Add pullscripts to your preprocessor list:

preprocessors: {
    './path/to/*.html': 'pullscripts',
},

Configure the file prefix:

pullscripts: {
    // Prefix referenced local file names with this before reading them up.
    filePrefix: 'dist/'
},

Note on order

All scripts are processed in order of appearance in the HTML files. For example if jquery is included before angular, then the jquery script will be downloaded and included before the angular script. If you have multiple html files with different scripts included, you might need to ensure the load order (order in files array) is consistent.

License

BSD

karma-preprocessor-pullscripts's People

Contributors

gyllstromk avatar jhendess avatar hagis avatar

Stargazers

Gabriel Chamon Araujo avatar

Watchers

 avatar  avatar

Forkers

gchamon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.