Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
apollo-mocknetworkinterface
Advanced tools
Network interface for mocking. See README.md for more information.
Supports both Apollo 1 & Apollo 2
To install the stable version:
npm install --save apollo-mocknetworkinterface@^1.0
Please read https://medium.com/p/ef0bbd17e686
import React from 'react';
import { ApolloClient, ApolloProvider, graphql } from 'react-apollo';
import renderer from 'react-test-renderer';
import MockNetworkInterface from 'apollo-mocknetworkinterface';
import query from './query.graphql';
const TestComponent = (props) => {
if (props.data.loading) {
return (<div>loading ... {JSON.stringify(props)}</div>);
}
return (<div>got data ... {JSON.stringify(props)}</div>);
};
const TestComponentWithApollo = graphql(query, {
options: props => ({
variables: { url: props.url },
}),
})(TestComponent);
const createResponse = (request) => { // pure function returning data
console.log('creating mocked response for request:', request); // eslint-disable-line no-console
// will log: creating mocked response for request: { query: { kind: 'Document' ...
return {
data: {
component: {
id: 1,
name: 'foo',
},
},
};
};
const mockedNetworkFetch = createMockedNetworkFetch(createResponse, { timeout: 100 }); // you can simulate network latency
const client = new ApolloClient({
link: createHttpLink({ uri: 'http://localhost:3000', fetch: mockedNetworkFetch }),
cache: new InMemoryCache(),
});
it('should render without exploding', (done) => {
const component = renderer.create((
<ApolloProvider client={client}>
<div>
<TestComponentWithApollo />
</div>
</ApolloProvider>
));
})
FAQs
Network interface for mocking. See README.md for more information.
We found that apollo-mocknetworkinterface 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.