I am trying to get intern-geezer (so far tested on 2.0.1 and 2.1.1) to work so I can perform tests on IE8 as well.
Currently I am trying to run tests on BrowserStack but unfortunately the test script seems to freeze and never return a response, so I have to stop the process manually.
My configuration is:
test/simpleTest.js
define(['intern!object', 'intern/chai!assert'], function (registerSuite, assert) {
registerSuite({
name: 'simpleTest',
sum: function () { assert.strictEqual(2 + 2, 4, 'Should sum'); }
});
});
test/intern-geezer.js
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
capabilities: { 'selenium-version': '2.41.0' },
environments: [
{ browserName: 'internet explorer', version: '9', platform: 'WINDOWS' }
],
tunnel: 'BrowserStackTunnel',
suites: [ 'test/simpleTest' ],
excludeInstrumentation: /^(?:test|node_modules)\//
});
Then calling intern-runner
./node_modules/intern-geezer/bin/intern-runner.js config=test/intern-geezer.js
Listening on 0.0.0.0:9000
Starting tunnel...
BrowserStackLocal v3.3
Ready
Initialised internet explorer 9 on WINDOWS
Then it keeps there forever doesn't matter what the environment is.
when checking BrowserStack for Exceptions, it seems this is the last operation step to run before it freezes:
Get URL⇒ http://localhost:9000/__intern/client.html?config=test%2Fintern-geezer.js&reporters=webdriver&functionalSuites=undefined&suites=test%2FsimpleTest&baseUrl=%2F&sessionId=f07e36f7e73786173ee0cfa98feb7e4b9bff3e2c
Any ideas?
Those tests work fine when using master branch of intern
The config command-line argument is supposed to be a module ID, not a filename. In other words, the .js needs to be removed.
Related
Today, for some unexplained reason my jest test files started looping, resulting in a flickering terminal.
I am running jest src --watch, src being my source folder.
I followed a number of other discussions but none of them have helped solve my issue.
https://github.com/facebook/jest/issues/4635 is talking about a custom processor, but I am using a default setup.
I have tried ignoring folders.
I have ended up removing all my test files, at which point the looping stops. If I add a test file to __tests__ it matches the file but does not run a test. If I add the test file to my /src folder, it starts looping again, and it doesn't matter if the actual test passes or fails. Even if I add a fake test with a simple
describe('Test Suite', () => {
test('two plus two is four', () => {
expect(2 + 2).toBe(4)
})
})
it loops and flickers.
This is my jest setup
"jest": {
"verbose": false,
"watchPathIgnorePatterns": [
"<rootDir>/dist/",
"<rootDir>/node_modules/"
],
"globalSetup": "./jest-setup.js",
"globalTeardown": "./jest-teardown.js",
"testEnvironment": "./jest-mongo.js"
},
Does anyone know what is causing this to loop? I am not changing any files in any folder to make the --watch think it needs to run again, there are no other apps i.e. dropbox syncing the folder.
I am developing in VSCode, but the same thing happens if I test in a terminal window.
This was running fine just 5 hours ago, what went wrong?
It turns out that the jest.setup file was writing a configuration file to disk, while setting up a temporary mongoDB. If at least one of the tests used the mongoDB the looping stopped, or if I removed the setup files the looping stopped.
So my problem started when out of 30 test files, the one that connected to mongo was edited (starting the looping/flickering). In trying to solve the problem I removed all the rest of the test files, which left me with the most basic tests, but still the looping because I was still not connecting.
Still not 100% sure of the exact mechanism, but when inheriting someone else's codebase which doesn't use the default jest setup, probably best to expand jest knowledge to understand what's going on.
I am trying to create an F# unit test project that runs in .net core.
dotnet new -t xunittest
will create an xunit test project for C#, but no such equivalent exists for F#.
I tried modifying the project.json and test file that get output from the C# "dotnet new" shown above, and add the bits I thought would be needed to make it run with F#. It didn't work. It builds and even "runs" a test after typing "dotnet test", but the test ALWAYS passes even when it shouldn't.
Am I missing something with the setup, or is there another (perhaps completely different) option I can pursue in order to create an F# test project? Again, I am specifically focused on making it work with .net core.
project.json
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"compilerName": "fsc",
"compile": {
"includeFiles": [
"Tests.fs"
]
}
},
"dependencies": {
"System.Runtime.Serialization.Primitives": "4.3.0",
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-*"
},
"tools": {
"dotnet-compile-fsc": "1.0.0-preview2.1-*"
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.1.0"
},
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629"
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
}
}
Tests.fs
module Tests
open Xunit
[<Fact>]
let ``Should Fail`` =
Assert.False true
Output from dotnet test
xUnit.net .NET CLI test runner (64-bit .NET Core win10-x64)
Discovering: FSTests
Discovered: FSTests
=== TEST EXECUTION SUMMARY ===
FSTests.dll Total: 0
SUMMARY: Total: 1 targets, Passed: 1, Failed: 0.
Your test is not a function, but a value. Compiled to IL as a property or field (depending on reasons). xUnit looks for methods to execute, it skips properties and fields (and rightly so: how would it execute them?)
Why is it not a function? Because it doesn't have a parameter. It's an F# thing: if you have parameters, you're a function. Otherwise - value.
Just give it a parameter, it will become a function. Don't have any meaningful parameters to add? Add a unit one - then it'll be compiled to IL as a parameterless static method.
[<Fact>]
let ``Should Fail`` () =
Assert.False true
One of my tests is failing intermittently when running the whole suite, but it doesn't fail when running it by itself.
I created a very basic repository with a vanilla application that reproduces the issue:
https://github.com/juanazam/ember-cli-test-issue.
Basically, I created a component with a text field and a button. The button is disabled while the text is empty.
The issues happens when two tests use the fillIn helper on the input.
Here is the testing code taken from the vanilla app:
test('test 1', function(assert) {
visit('/');
fillIn('input[type=text]', "Algo");
andThen(function() {
assert.equal(currentRouteName(), "index");
});
});
test('test 2', function(assert) {
visit('/');
andThen(function() {
assert.ok(find('input[type=submit]').is(':disabled'));
});
fillIn('input[type=text]', "Algo");
andThen(function() {
assert.ok(!find('input[type=submit]').is(':disabled'));
});
});
As you can see test 1 only fills the input but doesn't do anything with it. The second test tests if the button is disabled.
Test 2 fails intermittently when running the whole suite. If you run ember test -s it fails, if you reload the browser tab (re running the whole suite without restarting the server process) it passes. The same behavior happens with multiple runs (one run fails, the next succeeds).
I didn't create a twiddle reproduction case because the test runner doesn't behave the same way.
With you app:
ember test will always fail.
ember test --filter 'test 1' will always pass.
ember test --filter 'test 2' will always pass.
If you split your 2 test functions into different acceptance tests ember test will always pass.
Qunit in the browser tries to execute failing tests first. (I think to reduce the time until the most interesting failing tests are executed.). With ember -s your tests are always executed in order and tests are failing (I guess test 2 failes because test1 already filled your input and it is not initially disabled as expected).
When reloading qunit in browser after the first failed test, the failing test2 is executed first (and passes).
Also have a look on https://dockyard.com/blog/2014/04/17/ember-object-self-troll . There might be a problem within your component definition leading to the unexpectedly filled input in test2.
I'm trying to run some Jasmine tests in Karma but the tests are failing because it's saying that it ran 0 of 0 tests. Can someone tell me what I'm doing wrong?
The async request mock fires and hits the callback. Even when I go to the debugger, it says 2 tests completed in the debugger, but failing in the console. What gives?
describe('User Info Tests:', function () {
describe('Fetch User Info:', function () {
it("User Name should match", function(done) {
// mock async request
getUserProfile(1, 2, function (userProfile) {
var match = userProfile.displayName === 'Unit Test User';
expect(match).toBeTruthy();
done();
}, function (msg) {
done();
throw msg;
});
});
});
});
See the screenshot below of the debug console of the tests running. You will see the tests ran with a status of SUCCESS.
So the problem was I wasn't including the karam-requirejs plugin in the karam.conf.js file. Apparently it doesn't want you to include your own copy of require.js in the files collection. Once I added that plugin in, everything just worked.
frameworks: ['jasmine-jquery', 'jasmine', 'requirejs'],
plugins: [
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-jasmine-jquery',
'karma-jasmine',
'karma-requirejs'
],
Make sure the karma-requirejs plugin is actually installed through npm and in your package.json as well!
I'm trying to troubleshoot a unit test issue.
I used to have a mostly working Maven -> PhantomJS -> Qunit setup, but it was unpredictable so I took it apart to try to fix it.
I upgraded the software:
Qunit: 1.11.0
PhantomJS: 1.8
Phantom Qunit Runner Latest: https://github.com/jquery/qunit/tree/master/addons/phantomjs
I see the web GUI working. It runs and passes all 102 tests. The console prints this:
$ phantomjs --disk-cache=false runner.js http://localhost/ui/dcx/test.html
$ Took 16ms to run 0 tests. 0 passed, 0 failed.
If I comment out the exit command in the runner, it prints the console output for QUnit.done multiple times.
$ phantomjs --disk-cache=false runner.js http://localhost/ui/dcx/test.html
$ PhantomJS successfully loaded a page
$ QUnit.done callback fired
$ Took 15ms to run 0 tests. 0 passed, 0 failed.
$ QUnit.done callback fired
$ Took 1840ms to run 102 tests. 102 passed, 0 failed.
$ QUnit.done callback fired
$ Took 1841ms to run 102 tests. 102 passed, 0 failed.
$ QUnit.done callback fired
$ Took 1842ms to run 102 tests. 102 passed, 0 failed.
$ QUnit.done callback fired
$ Took 1848ms to run 102 tests. 102 passed, 0 failed.
$ ^C
$
Looks to me like the Qunit.done callback is getting executed too soon, then multiple times.
Anyone know why that callback fires?
My test inclusions and login delay might be relevant. I use AMD modules to define tests and curl.js to bring them in. Nothing happens until the security login does:
curl(['dolla'], function($){
$.ajax({
type: 'POST',
url: '/svc/j_spring_security_check',
data: {
j_username: '7',
j_password: '7'
},
success: function() {
loadTests()
}
});
})
var loadTests = function () {
curl([
// Unit tests
'dcx/dataControls/activity.test'
, 'dcx/dataControls/eventList.test'
, 'dcx/dataControls/mapViewer.view.test'
, 'dcx/pages/deviceDetails.view.test'
, 'dcx/pages/login.test'
, 'dcx/pages/nodeProfiles.test'
, 'dcx/pages/settings.view.test'
], function() {}, function(ex) { throw new Error(ex) })
})
EDIT:
I'm down to a root cause, I think.
If you include QUnit on a blank page, it calls QUnit.begin and QUnit.done right away.
I need to delay execution of Qunit until after the security login is successful and curl has brought in my unit tests. Is there a way to delay the start of QUnit, but still keep the Qunit object available? I can't use stop() because there are many async tests that will call start().
Found the answer. You can configure QUnit to not start, then start it manually when all your tests are loaded. This prevents the duplicate calling of Qunit.done which is the root cause of this issue.
http://forum.jquery.com/topic/are-qunit-and-requirejs-compatible#14737000001967123
This is one way to do it--modify the runner to not exit if there are not test results.
https://gist.github.com/SimpleAsCouldBe/5059623
This doesn't work though--Qunit.done fires whenever the test stack is cleared. In an asynchronously loaded environment like Curl/Require.js, this can happen any time.
This is if you don't want to use require. For example, in a browser context maybe.
Having spent ages to find a method to turn loading of scripts (and stylesheets) into Promises (see here), I then found big problems with QUnit test suites starting to run before all these had loaded. Typically a handful of tests, at the start, would complain than a certain variable or class was undefined, although later tests wouldn't have that difficulty.
You can stop automatic starting by going like this:
QUnit.config.autostart = false;
... seemingly just putting it in one of several files will suffice.
To start the QUnit tests, then, you have to go QUnit.start();. But, understandably perhaps, you can't execute this from inside any code which is being run by a QUnit test. This gets complicated. In the end I did this in my app-starting code:
await this.loadInjectedFile( GLOBAL_SCRIPT );
await this.loadInjectedFile( DBFORM_SCRIPT );
await this.loadInjectedFile( UDV_SCRIPT );
await this.loadInjectedFile( REACTIVITY_SCRIPT );
console.log( '... injected files loaded' );
// to allow QUnit to start testing
window.QUnitGreenLight = true;
... strictly speaking a naughty thing to do (allowing test-related code to sneak into your app code). A more compartmentalised approach could probably be found.
Then, inline in the HTML file from where you launch your testing:
<script>
const tryToStartTesting = function(){
setTimeout( function(){
if( window.QUnitGreenLight ){
QUnit.start();
}
else {
console.log( 'QUnit green light not yet given!' );
tryToStartTesting();
};
}, 10 );
};
tryToStartTesting();
</script>
... in practice it seems to take maybe a few hundredths of a second before the green light is given.
A bit scrappy, perhaps, but it seems to work.