🚀 DAY 2 OF LAUNCH WEEK: Unify Your Security Stack with Socket Basics.Learn more →
Socket
Book a DemoInstallSign in
Socket

karma-references

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

karma-references

A small utility for resolving script references and updating karma config

unpublished
latest
Source
npmnpm
Version
1.1.34
Version published
Maintainers
1
Created
Source

karma-references

utility for collecting script references and updating karma config

example usecase:

  • .ts files are compiled into .gen.js files (so that they can be easily distingueshed from legacy .js files)
  • .spec.ts files reference generated typings (to avoid repeated compilation of referenced files)(/// <reference path="../some/relative/path/module.gen.d.ts">)
  • these are transformed into .js references
  • forceTransform makes the collecting process fail if referenced file does not exist
  • references are synchronized using external file because karma.conf.js cannot handle async
    • and also to separate collection process from karma execution, allowing repeated test execution over collected references
    // collect.js
	const log = require("karma-references/lib/log");
	const logger = new log.MemoryLogger(log.LogLevel.debug);
	const jsref = require("karma-references/lib/jsref");

	jsref
		.collectReferences({
			folders: ["../../WebSite/js", "./specs"],
			filesInclude: ["*.spec.js"],
			outputExclude: ["*.ts", "*node_modules*"],
			referenceTransforms: [jsref.parseTransform("([.]gen[.]d)?[.]ts$;.js")],
			forceTransform: true,
			log: logger
		})
		.then(result => {
			console.log(result.files);
			const content = JSON.stringify(result.files, null, "\t");
        	const fs = require("fs");
			fs.writeFileSync("references.json", content);
		})
		.catch(err => {
			console.error(`error: ${err}`);
			console.error(logger.lines);
			process.exit(1);
		})
		;
   // karma.conf.js
   function getReferences() {
   	const fs = require("fs");
   	return JSON.parse(fs.readFileSync("references.json", "utf8"));
   }

   const preprocessors = ["coverage"];

   config.set({
       frameworks: ["jasmine"],
       files: getReferences(),
       preprocessors: {
           "../../WebSite/**/!(*.spec).js": preprocessors,
           "../../WebSite/**/!(*.spec).gen.js": preprocessors
       }
   });

Keywords

karma

FAQs

Package last updated on 24 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts