
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
mock-component
Advanced tools
NgMocks consolidates mock-component, mock-directive, and mock-pipe into one package making it easier to maintain.
Also, if you like mock-component/ng-mocks you may also like shallow-render.
Helper function for creating angular component mocks for test.
Sure, you could flip a flag on schema errors to make your component dependencies not matter. Or you could use this to mock them out and have the ability to assert on their inputs or emit on an output to assert on a side effect.
import { async, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MockComponent } from 'mock-component';
import { DependencyComponent } from './dependency.component';
import { TestedComponent } from './tested.component';
describe('TestedComponent', () => {
let fixture: ComponentFixture<TestedComponent>;
beforeEach(async() => {
TestBed.configureTestingModule({
declarations: [
MockComponent(DependencyComponent)
]
})
.compileComponents();
.then(() => {
fixture = TestBed.createComponent(ExampleComponentContainer);
component = fixture.componentInstance;
});
}));
it('should send the correct value to the dependency component input', () => {
// let's pretend Dependency Component (unmocked) has 'someInput' as an input
// the input value will be passed into the mocked component so you can assert on it
const mockedComponent = fixture.debugElement
.query(By.css('dependency-component-selector'))
.componentInstance as DependencyComponent; // casting to retain type safety
expect(mockedComponent.someInput).toEqual('foo'); if you casted mockedComponent as the original component type then this is type safe
});
it('should do something when the dependency component emits on its output', () => {
const mockedComponent = fixture.debugElement
.query(By.directive(MockComponent(DependencyComponent)))
.componentInstance as DependencyComponent; // casting to retain type safety
// again, let's pretend DependencyComponent has an output called 'someOutput'
// emit on the output that MockComponent setup when generating the mock of Dependency Component
mockedComponent.someOutput.emit(new Foo()); if you casted mockedComponent as the original component type then this is type safe
fixture.detectChanges();
// assert on some side effect
});
});
Report it as an issue or submit at PR. I'm open to contributions.
5.1.0 (2018-04-05)
<a name="5.0.0"></a>
FAQs
Function creating a mock based on a passed in component for test
The npm package mock-component receives a total of 4 weekly downloads. As such, mock-component popularity was classified as not popular.
We found that mock-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.