Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
zetavg committed Jan 19, 2025
1 parent a0c70fc commit 71e5222
Showing 1 changed file with 59 additions and 35 deletions.
94 changes: 59 additions & 35 deletions tests/rn-test-container/native-test.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
import { beforeAll, describe, expect, inject, it, test } from 'vitest'
import { remote } from 'webdriverio'
import { copy, copySync, ensureDirSync, move, pathExists } from 'fs-extra'
import type { remote } from 'webdriverio'
import { execSync } from 'node:child_process'
import path from 'node:path'

let hasSetup = false

async function setup() {
const root = process.cwd()
const tmpDir = path.join(root, 'node_modules', '.test')
ensureDirSync(tmpDir)

if (!process.env.TEST_CONTAINER_PATH) {
throw new Error('No TEST_CONTAINER_PATH provided')
}

const appPath = path.join(tmpDir, 'ios-test-container-prod.app' /* TODO: dev */)

copySync(

Check failure on line 20 in tests/rn-test-container/native-test.test.ts

View workflow job for this annotation

GitHub Actions / Native iOS Test (Prod)

Unhandled error

Error: ENOENT: no such file or directory, lstat 'tests/rn-test-container/build/Build/Products/Release-iphonesimulator/RNTestContainer.app' ❯ Object.lstatSync node:fs:1641:25 ❯ Object.lstatSync ../../node_modules/graceful-fs/polyfills.js:318:34 ❯ statFunc ../../node_modules/fs-extra/lib/util/stat.js:24:20 ❯ getStatsSync ../../node_modules/fs-extra/lib/util/stat.js:25:19 ❯ Object.checkPathsSync ../../node_modules/fs-extra/lib/util/stat.js:64:33 ❯ Proxy.copySync ../../node_modules/fs-extra/lib/copy/copy-sync.js:27:38 ❯ setup native-test.test.ts:20:3 ❯ native-test.test.ts:104:5 ❯ ../../node_modules/@vitest/runner/dist/index.js:146:14 ❯ ../../node_modules/@vitest/runner/dist/index.js:533:11 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errno: -2, code: 'ENOENT', syscall: 'lstat', path: 'tests/rn-test-container/build/Build/Products/Release-iphonesimulator/RNTestContainer.app' } This error originated in "native-test.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "native-test.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
process.env.TEST_CONTAINER_PATH,
appPath
)

// Need to pipe the output to the console
execSync(`yarn react-native bundle --platform ios --dev false --bundle-output ${appPath}/main.jsbundle --assets-dest ${appPath}`, { stdio: 'inherit' })
}

function getSimulatorUdid() {
if (process.env.SIMULATOR_UDID) {
Expand Down Expand Up @@ -76,49 +100,49 @@ describe('Native Test Test', () => {
test('should pass', () => {
getWebDriverOpts()
expect(true).toBe(true)
console.log(process.cwd())
setup()
})

test('hello world', async () => {
const driver = await remote(getWebDriverOpts())
// console.log(JSON.stringify(driver.commandList))
// driver.executeScript('mobile: terminateApp', [{ bundleId: 'host.exp.Exponent' }])
// driver.executeScript('mobile: launchApp', [{ bundleId: 'host.exp.Exponent' }])

// const screenShot = await driver.takeScreenshot()
// console.log('screenShot', screenShot)
await driver.saveScreenshot('./screenshot.png')

// Select with accessibility id
const element = driver.$('~hello-word')
// test('hello world', async () => {
// const driver = await remote(getWebDriverOpts())
// // console.log(JSON.stringify(driver.commandList))
// // driver.executeScript('mobile: terminateApp', [{ bundleId: 'host.exp.Exponent' }])
// // driver.executeScript('mobile: launchApp', [{ bundleId: 'host.exp.Exponent' }])

// expect element to contain text "Hello, World!"
const text = await element.getText()
expect(text).toBe('Hello One!')
// // const screenShot = await driver.takeScreenshot()
// // console.log('screenShot', screenShot)
// await driver.saveScreenshot('./screenshot.png')

// // Select with accessibility id
// const element = driver.$('~hello-word')

// const settingsItem = await driver.$('//*[@text="Settings"]');
// await settingsItem.click();
}, 10 * 60 * 1000)
// // expect element to contain text "Hello, World!"
// const text = await element.getText()
// expect(text).toBe('Hello One!')

test('hello world 2', async () => {
const driver = await remote(getWebDriverOpts())
// console.log(JSON.stringify(driver.commandList))
// driver.executeScript('mobile: terminateApp', [{ bundleId: 'host.exp.Exponent' }])
// driver.executeScript('mobile: launchApp', [{ bundleId: 'host.exp.Exponent' }])
// // const settingsItem = await driver.$('//*[@text="Settings"]');
// // await settingsItem.click();
// }, 10 * 60 * 1000)

// const screenShot = await driver.takeScreenshot()
// console.log('screenShot', screenShot)
await driver.saveScreenshot('./screenshot.png')
// test('hello world 2', async () => {
// const driver = await remote(getWebDriverOpts())
// // console.log(JSON.stringify(driver.commandList))
// // driver.executeScript('mobile: terminateApp', [{ bundleId: 'host.exp.Exponent' }])
// // driver.executeScript('mobile: launchApp', [{ bundleId: 'host.exp.Exponent' }])

// Select with accessibility id
const element = driver.$('~hello-word')
// // const screenShot = await driver.takeScreenshot()
// // console.log('screenShot', screenShot)
// await driver.saveScreenshot('./screenshot.png')

// expect element to contain text "Hello, World!"
const text = await element.getText()
expect(text).toBe('Hello One!')
// // Select with accessibility id
// const element = driver.$('~hello-word')

// // expect element to contain text "Hello, World!"
// const text = await element.getText()
// expect(text).toBe('Hello One!')

// const settingsItem = await driver.$('//*[@text="Settings"]');
// await settingsItem.click();
}, 10 * 60 * 1000)
// // const settingsItem = await driver.$('//*[@text="Settings"]');
// // await settingsItem.click();
// }, 10 * 60 * 1000)
})

0 comments on commit 71e5222

Please sign in to comment.