/* * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ // -- Testing with Mocha under Node task installDependenciesMochaNode(type: NpmTask, dependsOn: [npmInstall]) { args = ['install', "mocha@$mocha_version", "source-map-support@$source_map_support_version", '--no-save'] if (project.hasProperty("teamcity")) args += ["mocha-teamcity-reporter@$mocha_teamcity_reporter_version"] } def compileJsLegacy = tasks.hasProperty("compileKotlinJsLegacy") ? compileKotlinJsLegacy : compileKotlinJs def compileTestJsLegacy = tasks.hasProperty("compileTestKotlinJsLegacy") ? compileTestKotlinJsLegacy : compileTestKotlinJs // todo: use atomicfu-transformed test files here (not critical) task testMochaNode(type: NodeTask, dependsOn: [compileTestJsLegacy, installDependenciesMochaNode]) { script = file("$node.nodeModulesDir/node_modules/mocha/bin/mocha") args = [compileTestJsLegacy.outputFile, '--require', 'source-map-support/register'] if (project.hasProperty("teamcity")) args += ['--reporter', 'mocha-teamcity-reporter'] } def jsLegacyTestTask = project.tasks.findByName('jsLegacyTest') ? jsLegacyTest : jsTest jsLegacyTestTask.dependsOn testMochaNode // -- Testing with Mocha under headless Chrome task installDependenciesMochaChrome(type: NpmTask, dependsOn: [npmInstall]) { args = ['install', "mocha@$mocha_version", "mocha-headless-chrome@$mocha_headless_chrome_version", "kotlin@$kotlin_version", "kotlin-test@$kotlin_version", '--no-save'] if (project.hasProperty("teamcity")) args += [ "mocha-teamcity-reporter@$mocha_teamcity_reporter_version"] } def mochaChromeTestPage = file("$buildDir/test-page.html") task prepareMochaChrome(dependsOn: [compileTestJsLegacy, installDependenciesMochaChrome]) { outputs.file(mochaChromeTestPage) } prepareMochaChrome.doLast { mochaChromeTestPage.text = """