Version: 0.0.10
Last Updated: Unknown
Node scaffold for CircleCi. Acts as if you will be using surge for staging and AWS S3 for production.
Make sure you get the binary required. Follow https://github.com/wix/Detox/blob/master/docs/Guide.Expo.md
Add the following to the scripts file:
"e2e": "detox test --configuration ios.sim --reuse", "e2e:verbose": "detox test --loglevel verbose --reuse --configuration ios.sim --debug-synchronization 1000"
Add the following under the detox key:
"detox": { "configurations": { "ios.sim": { "binaryPath": "bin/Exponent.app", "type": "ios.simulator", "name": "iPhone 7" } } }
# key name detox: # building with mocha - mocha: tests: - homeTab: - name: 'ListItemTwo testing' components: - ListItemTwo actions: - exist: Home - waitFor: ListItemTwo - tap: ListItemTwo - tapVar: 'ListItemTwoCopy.items[1].id' - waitFor: ItemDetail - exist: ItemDetail - name: 'ListItemThree testing' components: - ListItemThree actions: - exist: Home - waitFor: ListItemThree - tap: ListItemThree - tapVar: 'ListItemThree.items[2].id' - waitFor: ItemDetail - exist: ItemDetail - name: 'ListItemSix testing' components: - ListItemSix actions: - exist: Home - waitFor: ListItemSix - tap: ListItemSix - tapVar: 'ListItemSix.items[2].id' - waitFor: ItemDetail - exist: ItemDetail - tabs: - name: 'Testing the tabs' actions: - exist: Home - tap: 'Login' - tap: 'Onboarding' - tap: 'Graphs' - tap: 'Other' - tap: 'Actions' - tap: 'Lists' - exist: Home
1const {reloadApp} = require('detox-expo-helpers');23<%_ if (typeof components !== 'undefined') components.forEach(function(d){ _%>4const <%= d %>Copy = require('../app/components/<%= d %>/copy.json');5<%_ }); _%>67describe('<%= filename %>', () => {8 beforeEach(async() => {9 await reloadApp();10 });11 <%_ if (typeof specs !== 'undefined') specs.forEach(function(spec){ _%>12 it('<%= spec.name %>', async() => {13 <%_ if (typeof spec.actions !== 'undefined') spec.actions.forEach(function(d){ _%>14 <%_ if (Object.keys(d)[0] === 'exist') { _%>await expect(element(by.id('<%= d[Object.keys(d)[0]] %>'))).toExist();<%_ } _%>15 <%_ if (Object.keys(d)[0] === 'waitFor') { _%>await waitFor(element(by.id('<%= d[Object.keys(d)[0]] %>'))).toExist();<%_ } _%>16 <%_ if (Object.keys(d)[0] === 'tap') { _%>await element(by.id('<%= d[Object.keys(d)[0]] %>')).tap();<%_ } _%>17 <%_ if (Object.keys(d)[0] === 'tapText') { _%>await element(by.text('<%= d[Object.keys(d)[0]] %>')).tap();<%_ } _%>18 <%_ if (Object.keys(d)[0] === 'tapVar') { _%>await element(by.id(<%= d[Object.keys(d)[0]] %>)).tap();<%_ } _%>19 <%_ }); _%>20 });21 <%_ }); _%>22});
1#!/usr/bin/env node23const fs = require('fs-extra');4const ejs = require('ejs');5const dir = __dirname;6const path = process.cwd();7const appDir = path;89/**10 * Build out detox e2e files for11 * React Native.12 *13 * @param {*} data14 */15const buildDetox = (data) => {16 ejs17 .renderFile(`${dir}/detox.ejs`, data, {}, function (err, str) {18 console.log(data);19 // str => Rendered HTML string20 if (err) {21 console.log(err);22 throw err;23 }2425 fs.outputFileSync(`${appDir}/e2e/${data.filename}.spec.js`, str);26 console.log('- Detox test created:', data.filename);27 });28};2930const buildInit = () => {31 ejs32 .renderFile(`${dir}/init.ejs`, {}, {}, function (err, str) {33 // str => Rendered HTML string34 if (err) {35 console.log(err);36 throw err;37 }3839 fs.outputFileSync(`${appDir}/e2e/init.js`, str);40 console.log('- Detox init file created');41 });42};4344const buildMochaOpts = () => {45 ejs46 .renderFile(`${dir}/mocha.ejs`, {}, {}, function (err, str) {47 // str => Rendered HTML string48 if (err) {49 console.log(err);50 throw err;51 }5253 fs.outputFileSync(`${appDir}/e2e/mocha.opts`, str);54 console.log('- Detox mocha opts file created');55 });56};5758/**59 * Bridge the CircleCi file60 *61 * @example62 * lift up up.yml63 *64 * @param {*} data65 */66module.exports = function (data) {67 console.log('Bridging Detox');68 try {69 // map the correct types across70 for (test of data.tests) {71 for (let key in test) {72 test[key].filename = key;73 buildDetox(test[key]);74 }75 }7677 buildInit();78 buildMochaOpts();79 } catch (err) {80 console.error(err);81 }82};
1require('babel-polyfill');2const detox = require('detox');3const config = require('../package.json').detox;45before(async() => {6 await detox.init(config);7});89after(async() => {10 await detox.cleanup();11});
1yarn add fs-extra ejs mocha expo-detox-hook detox-expo-helpers detox --dev
1--recursive --timeout 1200000 --bail