![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A utility library for testing React Native components using Detox
npm install --save-dev kompot
const Kompot = require('kompot');
//require the component that we want to test:
const component = Kompot.kompotRequire('../ChuckNorrisJokesPresenter');
//write some mocks:
component.kompotInjector({
MOCK_LAME_JOKE: () => {
const JokeService = require('../fetchJokeService');
JokeService.fetchJoke = async () => {
return Promise.resolve('This is a lame Chuck Norris joke')
}
}
})
describe('ChuckNorrisJokesPresenter', () => {
it('Should fetch a joke', async () =>
await component
.withProps({someProp: 'test'})
.withMocks(['MOCK_LAME_JOKE']) //use the mock that we specified above
.mount();
await expect(element(by.id('chuckNorisJoke'))).toHaveText('"This is a lame Kompot joke"');
})
});
You should use this method instead of the native require in order to require your component.
const component = Kompot.kompotRequire('../App').App;
See below about the returned component object.
Use this function when you need to mock things.
component.kompotInjector({
default: () => { //the default function will be called for each test.
const JokeService = require('../fetchJokeService');
JokeService.fetchJoke = async () => {
return Promise.resolve('A mocked joke fetched from the joke service!');
}
},
MOCK_LAME_JOKE: () => { //will be called only if the componet is mounting with the 'MOCK_LAME_JOKE' mock.
const JokeService = require('../fetchJokeService');
JokeService.fetchJoke = async () => {
return Promise.resolve('This is a lame Chuck Norris joke')
}
}
})
You can decide which mock will be activated when you are mounting the component with mocks:
component.withMocks(['MOCK_LAME_JOKE']).mount();
The default
mock will be always activated.
When you require a component, you get a component object with the following props:
usage: kompot-cli.js [-h] [-s] [-k] [-r] [-b appName]
[-t {react-native-navigation}] [-i filePath]
[-l filePath]
Optional arguments:
-h, --help Show this help message and exit.
-s, --start Launch react-native's packager.
-k, --kill Kill server and packager if needed.
-r, --run-server Start the Kompot server on port 2600
-b appName, --build appName
Scan the project for *.kompot.spec.js and process
them. app name should be the same name that you pass
to AppRegistry.registerComponent()
-t {react-native-navigation}, --app-type {react-native-navigation}
Application type.
-i filePath, --init-root filePath
A path to an initialization file, for custom
initializaion of the root component.
-l filePath, --load filePath
A path to a file that will be loaded before the
mounting of the component. Put all global mocks in
this file
FAQs
A utility library for testing React Native components using Detox
The npm package kompot receives a total of 3 weekly downloads. As such, kompot popularity was classified as not popular.
We found that kompot 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
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.