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.
pixels-catcher
Advanced tools
Library for testing React Native UI components and screens
$ npm install pixels-catcher --save
For the application integration only react-native-save-view is used which is required to convert View
to base64 data and has native implementation. Therefore the linking is required and this can be easily done with the following steps:
android/settings.gradle
file include the dependency:include ':react-native-save-view'
project(':react-native-save-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-save-view/android')
android/app/build.gradle
file add:dependencies {
compile project(':react-native-save-view') // <-- This
...
}
android/app/src/main/java/com/.../MainApplication.java
add it to packages list@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new SaveViewPackage() // <-- This
);
}
Create new entry file, for example, indexSnapshot
or check the demo project. You will need to import registerSnapshot
, runSnapshots
and Snapshot
from pixels-catcher
:
import {
registerSnapshot,
runSnapshots,
Snapshot,
} from 'pixels-catcher';
After that create the snapshot component, which should extend Snapshot
and implement static snapshotName
and renderContent
method. Be sure that your component can accept collapsable
property, otherwise React can does optimization and drop the view. The implementation can be:
class AppSnapshot extends Snapshot {
static snapshotName = 'AppSnapshot';
renderContent() {
return (<App />);
}
}
after that register it:
registerSnapshot(AppSnapshot);
and run snapshots:
runSnapshots(PUT_YOUR_APP_NAME_HERE);
Snapshots testing will be started as soon as the application is started.
In package.json
add the following the PixelsCatcher
sections according to
the following format:
PixelsCatcher: {
PLATFORM: {
...SHARED_CONFIGURATION,
CONFIGURATION: {
...CONFIGURATION_SPECIFIC
}
}
}
where
PLATFORM
can be android
or ios
CONFIGURATION
is a configuration with the following properties:
activityName
- Activity name, example: MainActivity.apkFile
- [Optional] Path to apk file, example: ./app/build/outputs/apk/debug/app-debug.apkemulatorName
- Emulator name, example: testemulatorParams
- [Optional] Array of emulator params like -no-audio, -no-snapshot, -no-window, etc.packageName
- Android package name, example: com.rumax.pixelscatcher.testappsnapshotsPath
- Path to snapshots, example: ./snapshotsImagesSHARED_CONFIGURATION
. In case more that one configurations exists, shared
parameters can be moved here.Example (or check demo project):
"PixelsCatcher": {
"android": {
"activityName": "MainActivity",
"emulatorName": "test",
"packageName": "com.rumax.pixelscatcher.testapp",
"snapshotsPath": "./snapshotsImages",
"debug": {
"emulatorParams": ["-no-audio", "-no-snapshot"],
"apkFile": "./android/app/build/outputs/apk/debug/app-debug.apk"
},
"release": {
"emulatorParams": ["-no-audio", "-no-snapshot", "-no-window"],
"apkFile": "./android/app/build/outputs/apk/debug/app-debug.apk"
}
},
"ios": { ... }
}
There are two options to run UI snapshots:
Using the generated apk file, provided via the apkFile
. In this case
pixels-catcher will open android emulator, install apk
file, execute all
the tests and will provide a report at the end. This scenario can be used
to integrate the screenshot testing with CI.
In cases apkFile
is not defined, the development mode will be used. This
means that only the server will be started and the application should be
started manually. This scenario can be used to debug snapshots, create
new reference images, etc.
To run tests execute the following command:
$ ./node_modules/.bin/pixels-catcher android debug
By default the index.android.js
file is used which refer to your application.
To fix it, in android/app/build.gradle
add the following config:
project.ext.react = [
entryFile: System.getProperty("entryFile") ?: "index.js",
bundleInDebug: System.getProperty("bundleInDebug") ?: true
]
And generate the apk
:
cd android && ./gradlew assembleDebug -DentryFile="indexSnapshot.js"
iOS i not supported yet.
Check the demo which includes an example how the snapshots can be done and also has some useful scripts that can be used to integrate with CI.
FAQs
UI snapshot testing for React Native
We found that pixels-catcher demonstrated a healthy version release cadence and project activity because the last version was released less than 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.