Skip to content
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

Try testing without a bundler, by setting NODE_PATH #2

Merged
merged 3 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
apps: mill

- name: Test
run: mill --no-server --jobs 0 test
run: mill --no-server _.test
nafg marked this conversation as resolved.
Show resolved Hide resolved

publish:
runs-on: ubuntu-latest
Expand Down
15 changes: 10 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,22 @@ trait CommonModule extends ScalaModule with CiReleaseModule with ScalafmtModule
)
}

object jsdeps extends CommonModule
object jsdeps extends CommonModule {
object test extends MillIntegrationTestModule {
override def millTestVersion = millVersion()
override def pluginsUnderTest = Seq(jsdeps)
}
}

//noinspection ScalaUnusedSymbol
object millbundler extends CommonModule {
override def moduleDeps = Seq(jsdeps)
override def ivyDeps = Agg(
ivy"com.lihaoyi::geny:1.0.0"
)
}

object test extends MillIntegrationTestModule {
override def millTestVersion = millVersion()
override def pluginsUnderTest = Seq(millbundler)
object test extends MillIntegrationTestModule {
override def millTestVersion = millVersion()
override def pluginsUnderTest = Seq(millbundler)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package io.github.nafg.millbundler.jsdeps

import mill._
import mill.modules.Jvm
import mill.scalajslib.TestScalaJSModule
import mill.scalajslib.api.JsEnvConfig

//noinspection ScalaUnusedSymbol,ScalaWeakerAccess
trait ScalaJSNpmModule extends ScalaJSDepsModule {
Expand Down Expand Up @@ -40,3 +42,16 @@ trait ScalaJSNpmModule extends ScalaJSDepsModule {
PathRef(dir)
}
}
//noinspection ScalaWeakerAccess
object ScalaJSNpmModule {
trait Test extends TestScalaJSModule with ScalaJSNpmModule {
override def jsEnvConfig = T {
val path = npmInstall().path / "node_modules"
println("path: " + path)
os.proc("ls", "react-phone-number-input")
.call(cwd = path, stdout = os.Inherit)
JsEnvConfig.NodeJs(env = Map("NODE_PATH" -> path.toString))
}
}

}
34 changes: 34 additions & 0 deletions jsdeps/test/src/simple/build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import $exec.plugins

import io.github.nafg.millbundler.jsdeps.ScalaJSNpmModule
import mill.scalajslib.api.ModuleKind
import mill.scalalib.{DepSyntax, TestModule}
import mill.scalajslib.api.JsEnvConfig


object main extends ScalaJSNpmModule {
override def scalaVersion = "2.13.10"
override def scalaJSVersion = "1.10.1"

override def ivyDeps =
Agg(
ivy"io.github.nafg.scalajs-facades::react-phone-number-input_3::0.16.0"
)

object test
extends Tests
with ScalaJSNpmModule.Test
with TestModule.Munit {

override def moduleKind = ModuleKind.CommonJSModule

override def ivyDeps =
super.ivyDeps() ++ Agg(ivy"org.scalameta::munit::0.7.29")
}
}

def verify = T {
val logger = T.ctx().log
val (_, testResults) = main.test.test()()
assert(testResults.nonEmpty, "No tests found")
}
File renamed without changes.
11 changes: 11 additions & 0 deletions millbundler/test/src/webpack-simple/main/test/src/Tests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import io.github.nafg.scalajs.facades.reactphonenumberinput._
import munit.Assertions._
import scala.scalajs.js
import scala.scalajs.js.annotation._


class Tests extends munit.FunSuite {
test("ReactPhoneNumberInput") {
assert(!js.isUndefined(ReactPhoneNumberInput.raw))
}
}