apply plugin: 'kotlin-platform-js' apply plugin: 'com.moowork.node' dependencies { expectedBy project(':common') compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" } tasks.withType(compileKotlin2Js.getClass()) { kotlinOptions { moduleKind = "umd" sourceMap = true metaInfo = true } } task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) { from compileKotlin2Js.destinationDir into "${buildDir}/node_modules" afterEvaluate { configurations.testCompile.each { from zipTree(it.absolutePath).matching { include '*.js' include '*.js.map' } } } } node { version = "$node_version" npmVersion = "$npm_version" download = true } task installDependencies(type: NpmTask) { args = ['install', 'mocha', 'source-map-support'] if (project.hasProperty("teamcity")) args += 'mocha-teamcity-reporter' } task prepareMocha(dependsOn: [compileTestKotlin2Js, populateNodeModules, installDependencies]) task runMocha(type: NodeTask, dependsOn: prepareMocha) { script = file('node_modules/mocha/bin/mocha') args = [compileTestKotlin2Js.outputFile, '--require=source-map-support/register'] if (project.hasProperty("teamcity")) args += '--reporter=mocha-teamcity-reporter' } test.dependsOn runMocha