Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
nest-commander-testing
Advanced tools
A testing utility for nest-commander. It builds on top of ideas from @nestjs/testing and is not tied to any test framework directly.
So you;'ve built a CLI application, but you want to test it, and you want to be able to do your usual NestJS DI mocking. Well, here's your solution :fireworks:
Before you get started, you'll need to install a few packages. First and foremost, this one:
nest-commander-testing
(name pending). You'll also need to install @nestjs/testing
as this
package makes use of them under the hood, but doesn't want to tie you down to a specific version,
yay peerDependencies!
npm i nest-commander-testing @nestjs/testing
# OR
yarn add nest-commander-testing @nestjs/testing
# OR
pnpm i nest-commander-testing @nestjs/testing
So what's the use of writing a super awesome command line script if you can't test it super easily,
right? Fortunately, nest-commander
has some utilities you can make use of that fits in perfectly
with the NestJS ecosystem, it'll feel right at home to any Nestlings out there. Instead of using the
CommandFactory
for building the command in test mode, you can use CommandTestFactory
and pass in
your metadata, very similarly to how Test.createTestingModule
from @nestjs/testing
works. In
fact, it uses this package under the hood. You're also still able to chain on the overrideProvider
methods before calling compile()
so you can swap out DI pieces right in the test.
A nice example of this can be seen in the basic.command.factory.spec.ts file.
If you are making use of the InquirerService
, you can use CommandTestFactory.setAnswers
method
and pass either a single answer or multiple answers depending on how many answers you need to mock.
In doing so, a mock inquirer service will act similarly to inquirer without needing to modify
process.stdin
or make use of any user input, allowing smooth testing in your CI pipelines. For an
example of this, please check the
pizza command integration test.
FAQs
A testing utility for nest-commander. It builds on top of ideas from @nestjs/testing and is not tied to any test framework directly.
The npm package nest-commander-testing receives a total of 10,606 weekly downloads. As such, nest-commander-testing popularity was classified as popular.
We found that nest-commander-testing 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.