• Stars
    star
    133
  • Rank 272,600 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ekke is a test runner for React-Native, it allows you to execute your test code directly on the device enabling you to test in the same environment as your production users.

EKKE

Greenkeeper badge

Ekke-Ekke-Ekke-Ekke PTANG Zoo Boing! Z' nourrwringmm...

ekke a unique new test runner for React-Native. Unlike other testing frameworks, it doesn't execute your tests in Node.js, with a bunch of mocks, but instead, it orchestrates the bundling and execution of tests directly inside your React-Native application. ekke allows your tests to fully access every API to the platform has to offer.

Why should you adopt Ekke for React-Native testing?

  • Platform independent The test runner does not contain any native code that means that every platform that React-Native supports now, or in the future will work out of the box.
  • Code confidence Tests run in the environment of your production code. No need to rely on imperfect mocks. Tests run on devices to guarantee API's match specifications.
  • Different test runners At its core, Ekke is nothing more than an orchestration tool. We have built-in support for different test runners.
  • Rendering It's not just unit tests. Ekke provides a rendering API that allows you to mount and render components in your test suite.


Ekke in action: running a test suite, streaming results back to the CLI

Installation

The module is released in the public NPM Registry and can be installed by running:

npm install --save ekke

After installation, you can integrate ekke into your project.

Table of Contents

Integration

Ekke needs a host application to run. That can either be the application you are currently developing or fresh installation of react-native init.

Not sure what to pick?

  • Application developers Using the application that you're currently developing is recommended. This allows your test suites to execute in precisely the same environment. Also, it will enable your test suites to leverage any NativeModule that your application might be consuming.
  • Library authors It depends on the library you're developing. If you are building a native add-on, or include NativeModules as dependencies, it's advised to create an example application in your project that has all native libraries linked. TODO: What is the alternative here, if there is one?

Integrating is as easy as importing ekke, and including the component in your app!

import { Ekke } from 'ekke';

function App() {
  return (
    <>
      <Ekke />

      <View>
        <Text>Your App Here</Text>
      </View>
    </>
  )
}

You can now run your tests by executing the run command of the ekke CLI:

# Make sure that the simulator of your choice is running.
react-native run-ios # or react-native run-android

ekke run glob/pattern/*.test.js more/test/files.js --using mocha

And now watch the magic unfold on your app.

If you are worried about shipping Ekke in your application, the component is using process.env.NODE_ENV to switch between development and production builds. Production builds will completely remove Ekke from your code. You can also conditionally include it { __DEV__ && <Ekke /> }.

Runners

At its core, Ekke is nothing more than an orchestration tool, it runs Metro bundler with a specific configuration, executes code automatically in the React Native environment, and reports back in the CLI. To run the test, we need to know which test runner you prefer so we can bundle it with the tests. The following runners are available:

mocha

To use Mocha make sure you have the testing framework as well as an assertion framework installed in your project:

npm install --save-dev mocha
npm install --save-dev assume # or any other assert framework, e.g. chai

Once all your dependencies finish installing, you can start writing your tests.

import { describe, it } from 'mocha';
import { render } from 'ekke';
import assume from 'assume';

describe('The best test suite in the world', function () {
  it('is amazing', function () {
    const amazing = 'amazing';

    assume(amazing).is.a('string');
    assume(!!amazing).is.true();
  });
});

Provide mocha as value to the --using flag to select it as test runner.

ekke run test.js --using mocha

The following Mocha options can be customized using the follow CLI flags:

  • --mocha.fgrep Only run tests containing this string. Defaults to ''.
  • --mocha.grep Only run tests matching this string. Defaults to ''.
  • --mocha.invert Inverts grep and fgrep matches. Defaults to false.
  • --mocha.ui Specify user interface. Defaults to bdd.
  • --mocha.reporter Specify reporter to use. Defaults to spec.
  • --mocha.slow Specify "slow" test threshold (in milliseconds). Defaults to 75.
  • --mocha.timeout Specify the test timeout threshold (in milliseconds). Defaults to 2000.
  • --mocha.bail Abort ("bail") after first test failure. Defaults to true.
  • --mocha.color Force-enable color output. Defaults to true.
  • --mocha.inlineDiffs Display actual/expected differences inline within each string. Defaults to true.
ekke run test.js --using mocha --mocha.reporter min --mocha.timeout 5000

Tape

Using tape as the test runner is pretty self-explanatory. You import tape into your test files and write your tests and assertions using provided by the framework.

import { render } from 'ekke';
import test from 'tape';

test('one', function (t) {
  t.plan(2);
  t.ok(true);

  setTimeout(function () {
    t.equal(1+3, 4);
  }, 100);
});

Once the tests are completed, simple tell ekke that you're --using tape to run the tests.

ekke run test.js --using tape

The will run your tests, and output the TAP (Test. Anything. Protocol) to your terminal which you can pipe to any of the Pretty Tap Reporters that you might have installed. For example, if you want to use tap-spec:

ekke run test.js --using tape | tap-spec

API

The API exposes the following methods:

Component

import { Ekke } from 'ekke';

The Ekke component controls the orchestration, execution, and rendering of the test suite. The component can be used as a wrapper, or as a regular component and be included in your application.

The component accepts the following optional properties:

  • interval, String, The component doesn't know when you are using the CLI, so it polls at a given interval, with an HTTP request, to the server that runs in the CLI to figure out if it's active and is waiting for tests to run. The lower the interval, the quicker your tests will be picked up by the component, but also the more performance it takes away from your app. Defaults to 10 seconds.
  • hostname, String, The hostname of your machine that the CLI server is running on. Defaults to localhost on iOS and 10.0.2.2 on Android.
  • port, Number, The port number that the CLI server is running on. Defaults to 1975.
  • alive, Function, Function to execute when the Ekke test runner is activated and is about to run the test suites.
//
// Stand alone.
//
<Ekke />

//
// Or wrap your app with it, you decide what is best for your application.
//
<Ekke>
  <App />
</Ekke>

To see an example of the implementation, take a look at our index.js file. It's what we use to test our code.

render

import { render } from 'ekke';

The render method allows you to render any React-Native component on the screen of the application.

import { View } from 'react-native';
import { render } from 'ekke';
import React from 'react';

describe('test', function () {
  it('renders a red square', function () {
    const ref = React.createRef();
    await render(<View style={{
      backgroundColor: 'red',
      width: 100,
      height: 100
    }} ref={ ref } />);

    //
    // You can now use ref.current to access the rendered view.
    // Not only that, but there's big red square on your app as well.
    //
  });
});

CLI

The ekke CLI is automatically installed in your node_modules when you install ekke in the project as a dependency. We use the CLI to communicate between the <Ekke /> component that you included in your application and the terminal.

The CLI should not be globally installed. Instead, you directly reference the locally installed binary from your package.json.

{
  "name": "your-super-awesome-package",
  "scripts": {
    "test": "ekke run test/*.js --using mocha"
  }
}

And run the scripts using npm.

npm test

# You can use the double dash support from npm to send additional flags:
# npm test -- --watch

Alternatively, you can use the npx command to execute the commands as well without the requirement of global installation of ekke:

npx ekke <commands here>

The following CLI commands are available:

run

ekke run <glob or files to run> --flags

The run command allows you to run your specified tests on the device that included the <Ekke /> React component. When you run the command, we will execute the following:

  • Start up the Metro bundler on the specified hostname and port.
  • Attach a WebSocket server on the created Metro bundler, for communication purposes.
  • Find all the test files you want to include based on the supplied glob.
  • Wait for the poll request from the <Ekke /> component.
  • Bundle all your tests, and the specified library using Metro Bundler.
  • Listen to progress events that are sent by <Ekke /> component over the WebSocket connection.
  • Proxy all the console.*, process.stdout to your terminal.
  • Close the CLI again with error code 0 or 1 depending on if your tests pass.

The run command assumes that all CLI arguments after the run command are the test files that need to execute inside React-Native. We allow single or multiple files, a glob pattern, or a combination of files and globs.

# Executes test/1.js, test/2.js, and then test/2.js using the mocha runner.
ekke run test/1.js test/2.js test/3.js --using mocha

# The same above, but done using a glob pattern to fetch all .js files
# from the test directory
ekke run test/*.js --using mocha

# Executes test/1.js and then all the .test.js files
ekke run test/1.js test/*.test.js --using tape

You can use the following CLI flags to change the behavior of the command:

  • --using {runner} This tells Ekke which runner should be used to execute your tests. Defaults to mocha See Runners for all runners.
  • --watch By default, we close the process with either an exit code 0 or 1 as an indication of the test results (0 passes, 1 failure). If you do not want the process to exit, you can use the --watch flag to keep the CLI process alive. Defaults to false.
  • --reset-cache The Metro Bundler caching system is enabled by default so that tests run in a performant way and don't always rebuild. Using this flag will disable the cache. Defaults to false.
  • --cache-location We already made sure that the Metro Bundler cache of your test doesn't collide with your test cache, but if you like to store it somewhere else you can change it with this flag. Defaults to os.tempdir()/ekke-cache.
  • --no-silent We silence the output of the Metro bundler by default, this allows you to see the Metro bundler output again. Defaults to false.
  • --hostname The hostname we should attach our Metro Bundler on. The hostname should be accessible by React-Native application. Defaults to localhost.
  • --port The port number we should use for the Metro Bundler, we don't want to clash with the Metro bundler of your react-native start command so it should be different, but still accessible by your React-Native application. Defaults to 1975 (The year Monty Python and the Holy Grail got released)
  • --require Files that should be required before your test suites are required Defaults to ¯_(ツ)_/¯, nothing

In addition to these default flags, any flag that you prefix with the name of the runner will be considered as options and used as configuration:

ekke run test.js --using mocha --mocha.timeout 3000

See the Runners for their specific configuration flags.

help

Display a list of all the available command their supported CLI flags. The help message is visible when you run ekke without, an unknown, or the help command:


ekke (v1.0.2)
Ekke-Ekke-Ekke-Ekke-PTANG. Zoo-Boing. Z' nourrwringmm...

COMMANDS:

run      Run the given glob of test files.
         --port           Port number that Metro Bundler should use.
         --hostname       Hostname that Metro Bundler should use.
         --using          Name of the test runner to use.
         --watch          Don't exit when the tests complete but keep listening.
         --no-silent      Do not suppress the output of Metro.
         --require        Require module (before tests are executed).
         --reset-cache    Clear the Metro cache.
         --cache-location Change the Metro cache location.
help             Displays this help message.
         --no-color       Disable colors in help message.

EXAMPLES:

$ ekke run ./test/*.test.js --using mocha

The output contains colors by default if you wish to remove those you can use the --no-color flag.

Debugging

Both the CLI and the react-native code bases use diagnostics under the hood for logging purposes. The logs are disabled by default but can be enabled by using the DEBUG feature flags. They both log under the ekke:* namespace.

The Ekke CLI

DEBUG=ekke* ekke <your command here>

React Native Component

import { AsyncStorage } from 'react-native';

AsyncStorage.setItem('debug', 'ekke*', function () {
  //
  // Reload your app, and the debug logs will now be enabled.
  //
});

For more detailed information about diagnostics, please see their project page.

Development

  • Fork Fork the repository to create a copy to your own GitHub account.
  • Clone Clone the newly created GitHub repo to your local machine.
  • Branch Create a fresh new branch from the master branch.
  • Install Run npm install to install dependencies and devDependencies.
  • Setup Run npm run setup to create development specific folders.
  • Hack Make your changes. Write tests covering your changes.
  • Test Run both npm test and npm test:ekke to ensure nothing got broken.
  • Push Commit and push your changes to fork.
  • Pull Request Create a pull request from your created branch to our master.
  • Review We'll review your change, and ask for updates if need.
  • Merge Virtual high fives are exchanged when your PR lands.

License

MIT

More Repositories

1

terminus

Graceful shutdown and Kubernetes readiness / liveness checks for any Node.js HTTP applications
JavaScript
1,831
star
2

kubernetes-client

Simplified Kubernetes API client for Node.js.
JavaScript
961
star
3

tartufo

Searches through git repositories for high entropy strings and secrets, digging deep into commit history
Python
457
star
4

procfilter

A YARA-integrated process denial framework for Windows
C++
397
star
5

compose-color-picker

Jetpack Compose Android Color Picker 🎨
Kotlin
375
star
6

svgs

svgs is a compatiblity layer between svg and react-native-svg
JavaScript
191
star
7

eslint-plugin-i18n-json

Fully extendable eslint plugin for JSON i18n translation files.
JavaScript
177
star
8

node-cluster-service

Turn your single process code into a fault-resilient, multi-process service with built-in REST & CLI support. Restart or hot upgrade your web servers with zero downtime or impact to clients.
JavaScript
166
star
9

godaddy.github.io

Deprecated version of GoDaddy blog. See https://github.com/godaddy/engineering.
HTML
163
star
10

smart-private-npm

An intelligent routing proxy for npm with support for: private, whitelisted, and blacklisted packaged
JavaScript
139
star
11

gasket

Framework Maker for JavaScript Applications
JavaScript
130
star
12

kubernetes-gated-deployments

Kubernetes Gated Deployments
JavaScript
123
star
13

activerecord-delay_touching

Batch up your ActiveRecord "touch" operations for better performance. ActiveRecord::Base.delay_touching do ... end. When "end" is reached, all accumulated "touch" calls will be consolidated into as few database round trips as possible.
Ruby
111
star
14

engineering

Jekyll website and blog showcasing open source projects by GoDaddy employees
HTML
84
star
15

yara-rules

YARA rules for use with ProcFilter
83
star
16

aws-okta-processor

Okta credential processor for AWS CLI
Python
82
star
17

warehouse.ai

A storage and developer workflow engine for enforcing arbitrary checks on ontologies of npm packages.
JavaScript
82
star
18

javascript

The official GoDaddy JavaScript styleguide.
JavaScript
76
star
19

asherah

Asherah is a multi-language, cross-platform application encryption SDK
C#
75
star
20

wp-reseller-store

Resell hosting, domains, and more right from your WordPress site.
PHP
62
star
21

react-img-carousel

A flexible image carousel built with React.js
JavaScript
60
star
22

jiractl

A command-line tool for managing Jira
JavaScript
56
star
23

lighthouse4u

LH4U provides Google Lighthouse as a service, surfaced by both a friendly UI+API, and backed by various storage clients (S3, ElasticSearch, etc) for all your query and visualization needs
EJS
56
star
24

slay

Rock-solid structured application layout for building APIs and web apps in Node.js.
JavaScript
49
star
25

next-rum

RUM Component for Next.js
JavaScript
48
star
26

timings

NodeJS/Express API to assert performance results during functional testing
JavaScript
45
star
27

addhoc

Handy little helper to create proper React HOC functions complete with hoisted statics and forwarded refs
JavaScript
41
star
28

datastar

A robust and feature rich ODM for Cassandra.
JavaScript
40
star
29

openstack-logstash

Logstash and Kibana configs for OpenStack Havana
JavaScript
37
star
30

node-openstack-wrapper

An OpenStack client for Node.js
JavaScript
33
star
31

gdapi-php

A PHP client for Go Daddy® REST APIs
PHP
31
star
32

opa-lambda-extension-plugin

A plugin for running Open Policy Agent (OPA) in AWS Lambda as a Lambda Extension.
Go
28
star
33

reduxful

Manage request data in Redux state by generating actions, reducers, and selectors automatically.
JavaScript
27
star
34

lazy-social-buttons

A JavaScript plugin to place social buttons on a page on user interaction (mouseover) to spare the initial page load from the 300kb+ download requests for social APIs.
JavaScript
25
star
35

serverless-aws-servicecatalog

An AWS Service Catalog enabling plugin for the popular Serverless project
JavaScript
24
star
36

react-safe-src-doc-iframe

A component which applies guards to srcdoc iframes in order to provide a predictable and safe experience to the user. Complements the sandbox native iframe attribute.
JavaScript
23
star
37

react-markdown-github

React component that renders Markdown similarly to Github's formatting
JavaScript
22
star
38

node-flipr

Feature flipping and configuration using yaml files.
JavaScript
21
star
39

domain-search

React-based domain search widget used for designing and building custom GoDaddy reseller storefronts
JavaScript
21
star
40

pullie

A GitHub bot that makes your PRs better
JavaScript
20
star
41

asset-system

asset-system is a cross platform SVG based asset system for React and React-Native. This mono-repo is the home for all asset-* packages.
JavaScript
20
star
42

docker-machine-godaddy

A Docker Machine driver plugin for GoDaddy Cloud Servers.
Go
19
star
43

carpenterd

Build and compile npm packages to run in the browser.
JavaScript
19
star
44

node-priam

A simple Cassandra driver for NodeJS. It wraps node-cassandra-cql with additional error/retry handling, external .cql file support, and connection option resolution from an external source.
JavaScript
19
star
45

external

Fitting for load React components from an external BigPipe server.
JavaScript
18
star
46

kibana4-backup

JavaScript
17
star
47

django-snow

ServiceNow Ticket Management App for Django based projects
Python
16
star
48

node-redis-ha

Redis high-availability client library for node
JavaScript
15
star
49

sample-size

This python project is a helper package that uses power analysis to calculate required sample size for any experiment
Python
14
star
50

node-config-shield

Safe and easy way for storing and retrieving sensitive data
JavaScript
13
star
51

bucket-service

A service to tag your tests to enable/disable without a code change
JavaScript
10
star
52

breakdancer

A breakpoint tracking utility
JavaScript
10
star
53

centos7-upgrade-scripts

Ansible playbook and supporting scripts for upgrading OpenStack compute/hypervisor hosts from CentOS 6 to 7
Shell
10
star
54

openstack-traffic-shaping

Python
9
star
55

tartufo-action

Searches through git repositories for high entropy strings and secrets, digging deep into commit history
Python
9
star
56

radpack

JavaScript
8
star
57

appetizer-bundle

Creates an uploadable bundle of your React-Native application so it can run on the appetize.io platform.
JavaScript
8
star
58

docker-node

Debian Docker images for Node.js with best practices in mind
Dockerfile
8
star
59

GDRouting

Objective-C
8
star
60

gdapi-python

A Python client for Go Daddy® REST APIs
Python
8
star
61

netmet

NetMet is networking tool that allows you to track and analyze network uptime of multi data centers installations
Python
7
star
62

godaddy-test-tools

gulp tools for testing node libraries with mocha and istanbul as well as linting using godaddy-style.
JavaScript
7
star
63

react-validation-context

Components for providing validation via React context.
JavaScript
7
star
64

openstack-ansible

Ansible playbooks for managing OpenStack infrastructure
7
star
65

out-of-band-cache

A generic cache for API clients with out-of-band refreshing
JavaScript
7
star
66

node-redirect-rules

JavaScript
7
star
67

exemplar

Deprecated: storybook rocket fuel to launch structured examples of React & React Native components
JavaScript
7
star
68

asherah-cobhan

Cobhan bindings for Asherah
Go
7
star
69

vault-cert-finder

Finds, parse and output X509 certificates stored in Hashicorp Vault
TypeScript
7
star
70

eslint-plugin-react-intl

Validation of locale ids used with react-intl functions/components like <FormattedMessage />, formatMessage and defineMessages.
JavaScript
7
star
71

gdapi-csharp

A C# client for Go Daddy® REST APIs
C#
6
star
72

tartufo-node

npm package shim for https://github.com/godaddy/tartufo
JavaScript
6
star
73

aws-liveness

AWS Liveness tools.
JavaScript
6
star
74

cobhan-go

Cobhan FFI is a system for enabling shared code to be written in Rust or Go and consumed from all major languages/platforms in a safe and effective way.
Go
6
star
75

cijtemplate

A template for continuous integration with Jenkins
Shell
6
star
76

lighthouse4u-lambda

Running Lighthouse4u in AWS Lambda
JavaScript
6
star
77

asherah-ruby

Application-layer encryption SDK
Ruby
6
star
78

node-http-cache

An extensible caching interface for HTTP traffic.
JavaScript
6
star
79

abstract-npm-registry

An test suite and interface for you can use to test various functional areas of an npm registry
JavaScript
6
star
80

asherah-python

Python
5
star
81

appetizer

A Node.js REST based API client for Appetize.io.
JavaScript
5
star
82

transform-url

Build URLs by transforming a template with params.
JavaScript
5
star
83

cobhan-python

Python wrapper library for the Cobhan FFI system
Python
5
star
84

node-connect-qos

Connect middleware that helps maintain a high quality of service during heavy traffic
TypeScript
5
star
85

timings-client-py

Python client for the timings API
Python
5
star
86

http-interception

Dumps requests and responses as newline delimited JSON that a browser performs when visiting a web page.
JavaScript
4
star
87

feedsme

Triggers appropriate rebuilds in the warehouse.ai system
JavaScript
4
star
88

mssql-pool-party

Extension of node mssql client providing failover, retry, stats, and more
JavaScript
4
star
89

cobhan-rust

Cobhan FFI is a system for enabling shared code to be written in Rust and consumed from all major languages/platforms in a safe and effective way.
Rust
4
star
90

short-css-vars

Optimize CSS variable names
JavaScript
4
star
91

spree_weight_based_shipping_calculator

Spree extension for weight-based shipping calculation
Ruby
4
star
92

joi-of-cql

Create cql type definitions from joi schema validations
JavaScript
4
star
93

hostwriter

API and CLI for querying and manipulating host files.
JavaScript
4
star
94

orglinter

A GitHub organization linting tool
JavaScript
3
star
95

gdapi-ui

An in-browser client for Go Daddy® REST APIs
JavaScript
3
star
96

carpenterd-worker

the worker process for carpenterd
JavaScript
3
star
97

node-gd-assets

CSS, JS, and Handlebars combiner, compressor, and server
JavaScript
3
star
98

node-http-cache-cassandra

A Cassandra provider for the extensible HTTP caching library http-cache.
JavaScript
3
star
99

cobhan-ruby

Ruby wrapper library for the Cobhan FFI system
Ruby
3
star
100

.github

Default community health files for GoDaddy Open Source
3
star