1.0.0 • Published 8 years ago
karma-graphql-preprocessor v1.0.0
karma-graphql-preprocessor
Preprocessor for converting GraphQL files into valid GraphQL queries.
Note: If you are using AngularJS, check out karma-ng-html2js-preprocessor.
Installation
The easiest way is to keep karma-html2js-preprocessor as a devDependency in your package.json.
{
"devDependencies": {
"karma": "~1.7.0",
"karma-graphql-preprocessor": "~1.0.0"
}
}You can simple do it by:
npm install karma-graphql-preprocessor --save-devor
yarn add karma-graphql-preprocessor --devConfiguration
// karma.conf.js
module.exports = function(config) {
config.set({
preprocessors: {
'**/*.gql': ['graphql']
},
files: [
'*.js',
'*.gql'
],
});
};How does it work ?
This preprocessor converts HTML files into JS strings and publishes them in the global window.__html__, so that you can use these for testing DOM operations.
For instance this template.html...
<div>something</div>... will be served as template.html.js:
window.__html__ = window.__html__ || {};
window.__html__['template.html'] = '<div>something</div>';See the end2end test for a complete example.
For more information on Karma see the homepage.
1.0.0
8 years ago
