![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
ng-directive-compiler-helper
Advanced tools
helper function for easier angularJS 1.x directive compilation in unit tests
A small helper function to ease the pain of testing Angular 1.x directives.
Usually you would have to set up directive compiler, give it a template, manage its attributes, parent or isolate scopes. This helper abstracts these things so you can focus on tests.
npm
$ npm install ng-directive-compiler-helper --save-dev
if using karma as test runner, make sure the following is in karma.conf.js
:
files: [
'node_modules/ng-directive-compiler-helper/lib/ng-directive-compiler-helper.js'
]
After including this package you will be able to use createCompiler
function. It requires directive template, $rootScope
and $compile
services:
compile = createCompiler(templateString, $rootScope, $compile)
compile
is now a function which can be used in two major ways:
compile(callbackFn)
;
* compile(parentScopeObject, callbackFn)
;
* compile(parentScopeObject, elementAttributesObject, callbackFn)
;most simple usage:
```js
compile((scope, element) => {
expect(scope).toBeDefined();
expect(element).toBeDefined();
});
```
scope
and element
properties:
* let compiled = compile()
;
* let compiled = compile(parrentScopeObject)
;
* let compiled = compile(parrentScopeObject, elementAttributesObject)
;most simple usage:
```js
expect(compile().scope).toBeDefined();
expect(compile().element).toBeDefined();
```
createCompiler
:let myDirectiveTemplate = '<my-directive></my-directive>';
let compile;
beforeEach(($rootScope, $compile) => {
compile = createCompiler(myDirectiveTemplate, $rootScope, $compile);
});
it('should compile', () => {
compile((scope, element) => {
expect(scope).toBeDefined();
// etc...
});
});
// adjust parent scope
it('should have parent scope values', () => {
compile({ parentScopeValue: true }, (scope, element) => {
expect(scope.parentScopeValue).toBe(true);
});
});
// adjust directive element attributes
it('should have additional attributes', () => {
// first param === parentScope, empty in this case
compile({}, { newAttribute: 'hello' }, (scope, element) => {
expect(element.attr('newAttribute')).toBe('hello');
});
});
it('should set isolate scope properties from attributes', () => {
// note that attribute properties are kebab-case and not camelCase!
compile({}, { 'isolate-scope-attribute': 'hello' }, scope => {
expect(scope.isolateScopeAttribute).toBe('hello');
});
});
FAQs
helper function for easier angularJS 1.x directive compilation in unit tests
We found that ng-directive-compiler-helper 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 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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.