does JavaScriptKit support Swift Testing?
naïvely, i tried making a Hello World test like this:
import Testing
@Test func test()
{
let document:JSValue = JSObject.global.document
let div:JSValue = document.createElement("div")
div.innerText = "Hello from Swift!"
_ = document.body.appendChild(div)
}
$ /swift/swift-DEVELOPMENT-SNAPSHOT-2025-03-25-a-ubuntu24.04/usr/bin/swift package \
--swift-sdk DEVELOPMENT-SNAPSHOT-2025-03-25-a-wasm32-unknown-wasip1-threads \
js test
error: no such module 'Testing'
5 |
6 | import Testing
| `- error: no such module 'Testing'
7 |
8 | @Test func test()
1 Like
JavaScriptKit's package plugin supports running swift-testing and XCTest test suites. Check this example: JavaScriptKit/Examples/Testing at main · swiftwasm/JavaScriptKit · GitHub
that example does not compile for me, if i remove the #if canImport(Testing)
gate.
@testable import Counter
import Testing
@Test func increment() async throws {
var counter = Counter()
counter.increment()
#expect(counter.count == 1)
}
@Test func incrementTwice() async throws {
var counter = Counter()
counter.increment()
counter.increment()
#expect(counter.count == 2)
}
error: no such module 'Testing'
1 | @testable import Counter
2 |
3 | import Testing
| `- error: no such module 'Testing'
4 |
5 | @Test func increment() async throws {
Ok, wasm32-unknown-wasip1-threads
doesn't support it yet.
1 Like