I'm writing a web component using StencilJS. One of the helper classes (ArrayHelper.ts) which is imported by my component has these import at the top:
import transform from 'lodash/transform';
import isEmpty from 'lodash/isEmpty';
import isEqual from 'lodash/isEqual';
import isObject from 'lodash/isObject';
this all works fine when compiling and serving locally. However, when writing some unit tests and executing them using jest, jest can't resolve these imports properly:
TypeError: isObject_1.default is not a function at Function.Object.
<anonymous>.ArrayHelper.toArray (/mycomponent/ArrayHelper.ts:15:35)
When I change the imports in ArrayHelper.ts to
import { isEmpty, isEqual, isObject, transform } from 'lodash';
then Jest will succesfully run the tests without problems but then the TS compilation by stencilJS doesn't work any more:
Missing Export: mycomponents/ArrayHelper.js:5:27
'isObject' is not exported by node_modules/lodash/lodash.js
Any ideas how to get these imports right for both situations?
Try import lodash like this
import * as _ from "lodash";
Try adding this to your stencil.config.js:
nodeResolve: {
browser: true
}
This is happening because lodash is not available where Jest is running your tests. Is it an experimental browser technology.
Refer - Link1 Link2
import * as transform from 'lodash/transform';
import * as isEmpty from 'lodash/isEmpty';
import * as isEqual from 'lodash/isEqual';
import * as isObject from 'lodash/isObject';
Related
I'm facing the console error issue with tinymce on vue.js. It works correctly both localhost and server hovewer editor throws me error on server (doesn't throw error on localhost).
console errors
Here is my import section
[I've tried import files both dynamically and statically, hovewer errors continue to exist]
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js">
import Editor from "#tinymce/tinymce-vue";
import "tinymce/tinymce";
// Theme
import "../../../../../../node_modules/tinymce/themes/silver/theme";
// Skins
import "../../../../../../node_modules/tinymce/skins/ui/oxide/skin.min.css";
import "../../../../../../node_modules/tinymce/skins/ui/oxide/content.min.css";
import "../../../../../../node_modules/tinymce/skins/content/default/content.min.css";
// Plugins
import "../../../../../../node_modules/tinymce/plugins/fullscreen";
import "../../../../../../node_modules/tinymce/plugins/paste";
import "../../../../../../node_modules/tinymce/plugins/autoresize";
import "../../../../../../node_modules/tinymce/icons/default";
</script>
I've solved my issue with writing :init="{content_css: false, skin: false}" property to editor tag
import org.openqa.selenium.*;
import org.openqa.selenium.JavascriptExecutor.executeScript;
You don't need executeScript in your import:
import org.openqa.selenium.JavascriptExecutor;
I have placed the logback-test.xml in classpath
karate.log is not getting generated, I have seen there is a file called main.log that gets generated sometime
Here is the project structure
Here is the runner file
package com.org.KarateLearning;
import com.intuit.karate.KarateOptions;
import com.intuit.karate.Results;
import com.intuit.karate.Runner;
import com.intuit.karate.junit4.Karate;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Map;
import java.util.Properties;
import static org.junit.Assert.assertTrue;
public class ParallelTestRunner {
#Test
public void parallel() {
Results res = Runner.path("classpath:features").tags("~#ignore").parallel(5);
assertTrue(res.getErrorMessages(),res.getFailCount()==0);
}}
I have tried placing logback-test.xml in resources and com.org.KarateLearning but karate.log is not getting genearted
Deleted the existing file ( logback-test.xml ) and created a new one from below path under src/test/java
https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/logback-test.xml
Now file is getting generated in target folder
In between it was getting generated outside of target folder. Now its getting generated at correct location inside target folder.
Also note even after deleting the logback-test.xml log was getting generated. (not sure about the reason for it)
Now all works well
I'm getting an error in Cucumber.class saying
cannot convert from class cucumber to calls runner
Here's my code:
package testRunners;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
//import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(features="resources/features", glue="StepDefinition")
public class Login {
}
It happens when you have dependency mismatch in your project. More details can be seen after digging in pom.xml. Please share it.
For now you should be knowing that #Runwith takes something which extends ParentRunner Class, so make sure the Cucumber.class that you are using here is extending ParentRunner.
I use Android Espresso Tests with latest Android Studio 2.1.2 and Tests are running ok but it does not seems like the standalone test app returns back the results to reflect back to Android Studio and it shows Running Tests Forever
I realize this is an old question, but I just ran into this and didn't see any other search results that had the same problem.
In my case, this was caused by the code under test having a stack overflow exception, which it seems that the test runner failed to handle. I was only able to figure it out by looking at the "Android Monitor" and looking in the logcat.
So if you get to the point where AS just sits at "running test" forever, you might want to look in logcat for an exception that the test runner couldn't handle.
You have to try removing testCoverageEnabled option from build.gradle file if it's there.
possible duplicate
Gradle build tool long for android Tests
In case this helps anyone.
In my case, I was setting the idle state wrongly(false instead of true) after doing a background task, so espresso was stuck thinking that was idle.
You can add an exit test class like this and include this in your Test Suite or Executor in the last
import android.os.Looper;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
import org.junit.FixMethodOrder;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import java.io.IOException;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
#RunWith(AndroidJUnit4.class)
#FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ExitTests {
#Rule
public ActivityTestRule<MainActivity> myActivityTestRule =
new ActivityTestRule<>(MainActivity.class, false, true);
public void init(){
getInstrumentation().waitForIdleSync();
if(Looper.myLooper() == null)
Looper.prepare();
}
#Test
public void Exit() throws InterruptedException, IOException {
Runtime.getRuntime().exec(new String[] {"am", "force-stop", "com.package.name"});
}
}
Here is the Test Suite
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
#RunWith(Suite.class)
#Suite.SuiteClasses({ABC.class, ExitTests.class})
public class TestExecutionOrder {
}