-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start on getting a test harness in place #25
Conversation
example/ios/xmtpreactnativesdkexampleUITests/xmtpreactnativesdkexampleUITests.swift
Outdated
Show resolved
Hide resolved
…native into unittestharness
func testRunTests() throws { | ||
// UI tests must launch the application that they test. | ||
let app = XCUIApplication() | ||
app.launch() | ||
|
||
// Go to unit tests page | ||
let button = app.buttons["Unit tests"] | ||
XCTAssert(button.waitForExistence(timeout: 3)) | ||
button.tap() | ||
|
||
// Make sure we're there | ||
let view = app.staticTexts["Test View"] | ||
XCTAssert(view.waitForExistence(timeout: 3)) | ||
|
||
// Wait for tests to complete | ||
let complete = app.staticTexts["tests-complete"] | ||
XCTAssert(complete.waitForExistence(timeout: 5)) | ||
|
||
// See if we have any failures | ||
if app.staticTexts["FAIL"].waitForExistence(timeout: 3) { | ||
// Take a screenshot so we can see what failed in the UI | ||
let screenshot = app.windows.firstMatch.screenshot() | ||
let attachment = XCTAttachment(screenshot: screenshot) | ||
attachment.lifetime = .keepAlways | ||
add(attachment) | ||
|
||
XCTFail("Tests failed.") | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's where we run the tests in Xcode, it's what should be run by xcode cloud when we set up CI.
</View> | ||
{result == "failure" && ( | ||
<Text | ||
testID="FAIL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what the Xcode runner looks for to determine failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes in this file were to handle supporting multiple clients.
@@ -2,6 +2,7 @@ | |||
{ | |||
"extends": "expo-module-scripts/tsconfig.base", | |||
"compilerOptions": { | |||
"lib": ["es2015", "DOM"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed this to fix some TS errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM from my end
@@ -24,5 +24,5 @@ Pod::Spec.new do |s| | |||
} | |||
|
|||
s.source_files = "**/*.{h,m,swift}" | |||
s.dependency "XMTP", "= 0.1.3-beta0" | |||
s.dependency "XMTP", "= 0.2.1-beta0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still confused why this works, because I still don't see a 0.2.1-beta0 version for the XMTP
cocoapod: https://github.com/search?q=repo%3ACocoaPods%2FSpecs+XMTP&type=commits
But if it works it works!
tests.push({ name, run: perform }); | ||
} | ||
|
||
// test("can fail", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: leftover commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this around for now just so I can uncomment it when I set up CI and make sure that's all working. Good eye though!
return client.address.length > 0; | ||
}); | ||
|
||
test("can message a client", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to me. Should probably add something to the read me about running the tests and running the local node for clarity when people clone/copy the code and can't get it working.
🎉 This PR is included in version 1.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Adds a screen in the RN example app where we can write tests. You can see the first couple of tests here.
You can also run the tests from Xcode, which just opens the example app, goes to the test screen then looks for failures (see here). In a follow up PR, we can wire up CI, I feel like this PR is big enough as is.
As part of getting tests working, I had to add support for letting multiple
Client
instances backed by the native client. That's some work we'll need to do on an Android side to get the tests to pass (cc @nplasterer).Note: You'll need to run a local node for the tests.