Seems like I can't access shouldMatchJson matcher from Kotlintest v3.4.2 the way is documented in https://github.com/kotlintest/kotlintest/blob/master/doc/matchers.md.
I get unresolved reference and I seem unable to import it. The code says it's an extension method to String class but tried with strings and even """{}""" but can't access that method. Am I doing something wrong? All other matchers are ok.
class Test : StringSpec ({
"Test a json" {
"{}".shouldMatchJson("{}")
}
})
Could it be that you are missing the import for the json extension?
I have this in my build.gradle:
testImplementation "io.kotlintest:kotlintest-assertions-json:3.4.2"
Related
I'm writing a gradle extension in an init-script but I don't know how to reference the extension in build.gralde.
// init.gradle.kts
allprojects {
extensions.create("message", MessageExtension::class)
}
open class MessageExtension(objects: ObjectFactory) {
// A configurable greeting
val greeting: Property<String> = objects.property()
}
I can reference message in groovy build.gradle, it's happy to pull message from thin air.
// build.gradle (groovy)
message.greeting = "hi"
But build.gradle.kts references to messages are unresolved.
// build.gradle.kts
message.greeting = "hi"
// ^ Unresolved reference: message
If I try to find the extension by type the class is also unresolved.
// build.gradle.kts
val messages = project.extensions.findByType(MessageExtension::class)
// ^ Unresolved reference: MessageExtension
I've tried declaring a package in my init.gradle.kts and importing it, but the import is also unresolved.
Try this in your build.gradle.kts:
the<MessageExtension>().greeting = "hi"
I'm learning how to use Dagger 2 and MVP architeture.
But I'm stuck in this error now:
Unresolved reference: DaggerHelloComponent
Look, this is my module:
#Module
class HelloModule {
lateinit var activityDagger: HelloActivityDagger
constructor(activityDagger: HelloActivityDagger) {
this.activityDagger = activityDagger
}
#Provides
fun providesHelloPresenter(): HelloActivityPresenterDagger = HelloActivityPresenterDagger(activityDagger)
}
and my component:
#Component(modules = [HelloModule::class])
interface HelloComponent {
fun inject(activityDagger: HelloActivityDagger)
}
So when I try to builder this component like this DaggerHelloComponent.create().inject(this) in my HelloActivityDagger shows me the error above.
Anyone know what I am doing wrong?
Cause I can see whats wrong in this code.
Oh, I already have followed this kapt things from this question Unresolved reference DaggerApplicationComponent and nothing happens
EDIT
To be more readable I`ve uploaded my project to Git. https://github.com/luangs7/DaggerMvpExample
Putting this code in the MyApplication class works for me to create the module starting off from your GitHub project - after the first failed build, kapt generates the DaggerHelloComponent class, and I can import it.
import android.app.Application
import br.com.squarebits.mvpexample.DaggerMvp.componentes.DaggerHelloComponent
import br.com.squarebits.mvpexample.DaggerMvp.componentes.HelloComponent
import br.com.squarebits.mvpexample.DaggerMvp.modules.HelloModule
class MyApplication : Application() {
val component: HelloComponent by lazy {
DaggerHelloComponent.builder()
.helloModule(HelloModule(HelloActivityDagger()))
.build()
}
}
If this is not happening at all, you should try the usual debugging steps of restarting Studio with File -> Invalidate Caches / Restart, cleaning and rebuilding your project, etc. Perhaps try pulling the GitHub repo to a new location and see if that builds for you - the code isn't the problem.
When I try to use either cold or hot functions from jasmine-marbles, I keep getting TypeError: Class constructor Observable cannot be invoked without 'new'. Anybody know how to resolve this error? Here is what I have below.
import { hot, cold } from "jasmine-marbles";
import { Observable } from "rxjs/Observable";
const myAction = hot("--a-", { a: "TEST" };
I started to get this error after i changed "target" property in tsconfig.json (at project root) to "es6", thus i restored to old good "es5"
Get warning "Not covered by Flow"(3 warnings on one line)
on line:
Use Flow.js v.0.48.0.
Code sample:
...
import { Font, AppLoading } from 'expo';
...
export default class App extends Component {
...
componentDidMount() {
this.loadFonts();
}
async loadFonts () {
await Font.loadAsync(fontsStore);
}
...
}
In this case, it looks like Flow is unable to find types for the expo module. It looks like they are not currently available on flow-typed, but you are welcome to submit them. You can also just create library definitions for your own use. Basically you will need to describe the external interface of the expo package. Flow will then use the types you provide to type check your code that uses the expo package.
Currently I'm using Babel to write a Node.js backend in ES6. Unfortunately I encountered a strange behaviour when extending a specific class. Some of my methods, defined in the extending class, are undefined. Unless I use the ES7 syntax to bind them to a property.
This is the actual code that gives me this strange behaviour:
import { Router } from 'express';
class MyCustomRouter extends Router
{
constructor() {
super();
this.methodWorks(); // works like a charm.
this.methodDoesnt(); // throws TypeError: _this.methodDoesnt is not a function
}
methodWorks = () => {
// some content
}
methodDoesnt() {
// some content
}
}
This is actually extends the Router from the expressjs library. So right now I'm just curious if someone could explain this behaviour and/or if there is a way to fix this.
I went looking inside the code of ExpressJS itself to find some explanation. Apparently they like to return a whole new and different context from the Router's constructor. Which explains why this is totally different and not containing my methods...