Gathering detailed insights and metrics for scuri
Gathering detailed insights and metrics for scuri
Gathering detailed insights and metrics for scuri
Gathering detailed insights and metrics for scuri
Automate Angular unit test and boilerplate with this schematic.
npm install scuri
Typescript
Module System
Node Version
NPM Version
TypeScript (98.17%)
Shell (1.24%)
Dockerfile (0.26%)
JavaScript (0.16%)
PowerShell (0.16%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
69 Stars
485 Commits
7 Forks
2 Watchers
31 Branches
2 Contributors
Updated on Jun 24, 2025
Latest Version
1.4.0
Package Id
scuri@1.4.0
Unpacked Size
255.58 kB
Size
61.13 kB
File Count
73
NPM Version
9.5.1
Node Version
18.16.1
Published on
Jul 16, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Powered by Schematics and TypeScript compiler
VS Code extension available!
🤙Have some feedback or need a feature? SCuri discussion on github
🤵Need commercial-quality coverage for SCuri?
After a component has been created it is boring and tedious to do the tests - and we often don't. SCuri* tries to jump-start that by walking the component's constructor, parsing the dependencies and creating mocks for each of them, and then including them in the spec.
The video shows how to use schematics scuri:spec --name src\app\my-com\my-com.component.ts
to create a spec from scratch (if already created see update or use --force to overwrite).
For Angular CLI >= 6
ng g scuri:spec --name src\app\my-com\my-com.component.ts
could be used instead.
--name is now optional
ng g scuri:spec my-com.component.ts
ornpx schematics scuri:spec my-com.component.ts
See details down here.
Shows how we begin with an outdated test:
it
test case for one of the public methods (getData
)HttpClient
to instantiate the componentAnd after schematics scuri:spec --name src\app\my-com\my-com.component.ts --update
command we get the updated test - dependency and a scaffold test case added.
For Angular CLI >= 6
ng g scuri:spec --name src\app\my-com\my-com.component.ts --update
could be used instead.
See details down here
Generates an
autoSpy
function that takes a type and returns an object with the same type plus all its methods are mocked i.e. jasmine.spy()
or jest.fn()
.
See details down here. Needs tsconfig path setup -> there.
Using VS Code? Just install the SCuri VS Code extension
Install deps
1npm install -D scuri 2ng g scuri:spec --name src/app/app.component.ts
Generate autospy
1ng g scuri:autospy
Tell Typescript where to find autoSpy
by adding autoSpy
to paths
:
1{ 2 ... 3 "compilerOptions": { 4 ... 5 "baseUrl": ".", 6 "paths": { 7 "autoSpy": ["./src/auto-spy"] 8 } 9 } 10}
Details here
Start using scuri:
1ng g scuri:spec --name src/app/app.component.ts
If you get Error: Invalid rule result: Function().
see the troubleshooting section below.
1ng g scuri:spec --name src/app/app.component.ts
or
1npx schematics scuri:spec --name src/app/app.component.ts
Requires --name
- an existing .ts
file with one class
(Component/Service/Directive/etc.) and NONE existing .spec.ts
file.
1ng g scuri:spec --name src/app/app.component.ts --force
or
1npx schematics scuri:spec --name src/app/app.component.ts --force
Requires --name
- an existing .ts
file with one class
(Component/Service/Directive/etc.). Will overwrite any existing .spec.ts
file.
This might be useful in certain more complex cases. Using a diff tool one could easily combine the preexisting and newly created (overwritten) content - just like a merge conflict is resolved.
1ng g scuri:spec --name src/app/app.component.ts --update
or
1npx schematics scuri:spec --name src/app/app.component.ts --update
Requires --name
- an existing .ts
file with one class
(Component/Service/Directive/etc.) and one existing .spec.ts
file where the update will happen.
To generate an auto-spy.ts
file with the type and function which can be used for automating mock creation, use:
ng g scuri:autospy
See the Autospy wiki page.
bash npm i -g @angular-devkit/schematics-cli npm i -D scuri schematics scuri:autospy --legacy
Notice the --legacy flag. It's required due to typescript being less than 2.8. See flags belowng g scuri:autospy --for jest
Or
schematics scuri:autospy --for jest
Versions and flags
angular | jest / jasmine | command |
---|---|---|
2,4,5 | jasmine | schematics scuri:autospy --legacy |
jest | schematics scuri:autospy --for jest --legacy | |
6, 7, 8 and up | jasmine | ng g scuri:autospy |
jest | ng g scuri:autospy --for jest |
All Angular versions after and including 6 can use the Angular CLI - ng generate scuri:autospy
.
Flags:
--for
with accepted values jest
and jasmine
(default is jasmine
)--legacy
for generating a type compatible with typescript < 2.8 (namely the conditional types feature)Examples:
ng g scuri:autospy --for jest --legacy
would generate a ts<2.8, jest-compatible autoSpy
type and function
ng g scuri:autospy
would generate a ts>2.8, jasmine-compatible autoSpy
type and function
After creating the auto-spy.ts
file as a result of the scuri:autospy
schematic invocation we need to make sure its properly imported in our tests. To that end and keeping in mind that autoSpy
is being imported in the created tests as import { autoSpy } from 'autoSpy';
. To make that an actual import one could add this line to tsconfig.json
:
1{ 2 "compilerOptions": { 3 "baseUrl": ".", // This must be specified if "paths" is. 4 "paths": { 5 "autospy": ["./src/auto-spy"] // This mapping is relative to "baseUrl" 6 } 7 } 8}
This is assuming auto-spy.ts
was created inside ./src
folder. Edit as appropriate for your specific case.
See here for path details
--force
)it
test case for each public methodit
-s for newly added public methodsscuri:autospy
(support jest, jasmine and ts with and w/o conditional types)--update
)
setup
function when missingautoSpy
function automatically - now imported as import { autoSpy } from 'autoSpy';
What's with the name?
A spec generator schematic - Spec Create Update Read (class - component, service, directive and dependencies) Incorporate (them in the spec generated/updated)
Scuri can use configuration from the following list by default (package.json .scurirc .scurirc.json .scurirc.yml .scurirc.yaml scurirc.js scurirc.config.js).
1{ 2 "name": "my-app", 3 ... 4 "scuri": { 5 "classTemplate": "src/templates/__specFileName__.template", 6 "functionTemplate": "src/templates/__specFileName__.template" 7 } 8}
1{ 2 "classTemplate": "src/templates/__specFileName__.template", 3 "functionTemplate": "src/templates/__specFileName__.template" 4}
Head over to the custom template guide or see the short explanation below:
Try using __specFileName__.template
for your template name. The __specFileName__
gets interpreted while creating the spec. There are other variables available too - see the custom template guide
To workaround the Error: Invalid rule result: Function().
install schematics separately and call scuri
with that.
1npm install -D scuri 2npm i -g @angular-devkit/schematics-cli 3schematics scuri:spec --name src/app/app.component.ts
or if you don't want to install the schematics
cli globally and have npm version 6 and above
you can
1npm install -D scuri @angular-devkit/schematics-cli 2npx schematics scuri:spec --name src/app/app.component.ts
Available as part of the Tidelift Subscription
The maintainers of SCuri and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open-source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
Thanks goes to these wonderful people (emoji key):
Georgi Parlakov 💻 🤔 📖 ⚠️ | Tzi Yang 🐛 | fgisslen 🐛 | danjor 🐛 | Dependabot 🚧 | OSHistory 🐛 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
You like the project and it gives you value? You are considering supporting it? That would be really appreciated!
No vulnerabilities found.
Reason
security policy file detected
Details
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More