Kotlin Test library for experimental WebAssembly JS platform - provides test framework adapters and assertions for testing Kotlin/Wasm applications that target JavaScript environments
—
Automatic integration with JavaScript testing frameworks, enabling seamless execution of Kotlin/WASM tests in various JavaScript environments without requiring manual configuration.
The library automatically detects and integrates with popular JavaScript testing frameworks, requiring no manual configuration from developers.
Supported Frameworks:
Detection Logic:
describe and it functions in the global scopeJasmine/Mocha/Jest Example:
<!DOCTYPE html>
<html>
<head>
<title>Kotlin WASM Tests</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.8.0/jasmine.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.8.0/jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.8.0/boot.js"></script>
</head>
<body>
<script src="your-kotlin-wasm-tests.js"></script>
<!-- Tests run automatically - no additional setup needed -->
</body>
</html>Node.js with Mocha:
# Install Mocha
npm install --save-dev mocha
# Run tests - framework detection happens automatically
npx mocha your-kotlin-wasm-tests.jsTeamCity Integration:
# TeamCity build configuration
# No special setup needed - TeamCity format is detected automatically
script: |
node your-kotlin-wasm-tests.js
# Test results appear in TeamCity test tab automaticallyFull support for asynchronous testing with JavaScript Promises, including proper error handling and test completion detection.
Promise-Based Tests:
import kotlin.test.*
import kotlin.js.Promise
class AsyncIntegrationTests {
@Test
fun fetchDataTest(): Promise<*> {
return fetchUserData("user123").then { userData ->
assertNotNull(userData)
assertEquals("user123", userData.id)
assertTrue(userData.isActive)
}
}
@Test
fun errorHandlingTest(): Promise<*> {
return fetchUserData("invalid-id")
.then {
fail("Should have thrown an error for invalid ID")
}
.catch { error ->
// Error is properly converted and reported by the framework
assertTrue(error.toString().contains("User not found"))
}
}
@Test
fun chainedAsyncTest(): Promise<*> {
return createUser("newuser@example.com")
.then { user ->
assertEquals("newuser@example.com", user.email)
return@then updateUserProfile(user.id, "John Doe")
}
.then { updatedUser ->
assertEquals("John Doe", updatedUser.name)
}
}
}Seamless error reporting that preserves Kotlin stack traces and exception details in JavaScript testing frameworks.
Error Conversion Features:
Example Error Output in Jasmine:
AssertionError: Expected <42> but was <43>
at assertEquals (kotlin-test.js:123:45)
at MyTests.calculateTest (my-tests.kt:15:8)
at Object.it (jasmine-adapter.js:67:12)Zero Configuration: The library requires no manual setup or configuration files. Framework detection and integration happen automatically when tests are executed.
Environment Requirements:
Framework Compatibility:
@Test, @BeforeTest, @AfterTest annotations - they work across all supported frameworksPromise<*> from test functions for async operationsError Handling:
Performance:
This automatic integration ensures that Kotlin/WASM tests run seamlessly in any JavaScript testing environment without requiring developers to learn framework-specific APIs or configuration details.
Install with Tessl CLI
npx tessl i tessl/maven-org-jetbrains-kotlin--kotlin-test-wasm-js