Git Product home page Git Product logo

karma-intellij's People

Contributors

greenkeeperio-bot avatar segrey avatar vojtajina avatar zzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

karma-intellij's Issues

WebStorm does not notice browser capturing

After updating WebStorm 7 EAP to 130.958, WebStorm does not see that a browser has been captured (still displays "Waiting for browser capturing...")

I know, it used to parse the Karma output to figure that out, however I don't see that code in the plugin anymore, so not sure what happend.

Karma does not pick up changes in tests with webpack

(Related to WEB-40931)

As the title mentions, Karma does not pick up changes in tests. More specifically, the error can be reproduced by:

  1. Run Karma (through karma-intellij) with all tests passing
  2. Change a test to make it fail intentionally (while the Karma server is still running in the background)
  3. Re-run the tests (through karma-intellij)
  4. Karma still shows that all tests are passing (although they obviously shouldn't).

I have created a repo for reproduction with minimal setup here: https://github.com/michael-markl/karma-intellij.

As found out in this comment, commenting out the two lines

    config.autoWatch = false;
    config.autoWatchBatchDelay = 0;

in intellij.conf.js solves the issue. However, I am unsure about the consequences in other project setups. Maybe, it would be useful to keep autowatch configurable?

Upgrade to work with 0.9.6

WebStorm does work with 0.9.5, but not with 0.9.6 - I assume that's because the runnerPort and port got merged - there's only port now.

Also, the communication between karma run and karma server happens through HTTP, so you WebStorm can directly send the HTTP to Karma server if you like.

Karma-intellij with karma-webpack does not wait for webpack to recompile

Hello,

I'm using karma-intellij with karma-webpack (https://github.com/webpack-contrib/karma-webpack) to point to a webpack configuration file in my karma.webpack.conf.js. One option karma-webpack provides is to use webpackBlocker, which is specified as a beforeMiddleware in the karma configuration:

 beforeMiddleware: [
   'webpackBlocker'
 ],

This middleware should block Karma from executing tests if code is recompiling, but it doesn't seem to produce the desired effect in karma-intellij. I can't reproduce this issue outside of Intellij (debugging through a browser or watching the Karma server output in a console).

Without this option, it's possible to make a code change, run the tests, and be unaware that they are actually executing against an outdated compilation.

I noticed setting the refresh flag to true in the POST request to Karma seems to solve the issue, regardless of if webpackBlocker is being used or not - (see https://github.com/karma-runner/karma-intellij/blob/master/lib/intellijRunner.js#L75) but I'm not sure that's the appropriate solution.

Make it possible for cmd+S to trigger a test run

right now it doesn't seem to be possible to have a single shortcut to both save files and trigger a test run.

even if I reconfigure the keyboard mappings so that cmd+S triggers test rerun in addition to saving all files it doesn't work.

Allow user to set a working directory

I just ran into the problem that the "karma-chai-plugins" plugin uses the working directory to resolve a path. There is no way to set this in this plugin. Please add it to the configuration settings, just like when creating a node.js configuration.

webpack preprocessor not running

I've got my tests setup w/ webpack and coverage preprocessors. These work as expected via CLI, but when I try to run via karma-intellij I get the following error (which makes me think the preprocessor isn't running):

SyntaxError: Use of reserved word 'import'
at http://localhost:9876/base/unit/attributes.spec.js?bf8f6bdd21402ea57b8260880929c7b7742f7d4b:57

Here's the config file I'm trying to use:

https://github.com/krux/prescribe/blob/jnewman-repro-intellij-integration-issue/test/karma-idea.config.js

Any pointers would be helpful. I've got a similar setup w/ coffee script preprocessors that works exactly as planned, so I'm wondering if it's something specific about multiple preprocessors.

For reference, I've attached images of my setup:

screen shot 2016-04-26 at 5 09 15 pm
screen shot 2016-04-26 at 5 19 02 pm

IntelliJ details:

IntelliJ IDEA 2016.1.1
Build #IU-145.597, built on March 29, 2016
JRE: 1.8.0_40-release-b132 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Exclude the user's karma.conf.js

By default, Karma does exclude the configuration file, so that it does not get loaded in the browser.

So I can use *.js pattern and it won't load karma.conf.js. It does explicitly ignore the config file that is being used.

WebStorm plugin does wrap the config file and therefore Karma is loading a different config file and does not ignore the user config file.

It should add the original - user's config file to excludes.

An example how to reproduce it can be https://github.com/vojtajina/testability-interview

Displaying coverage results

When using JSTestDriver, you get some nice extra info about code coverage (e.g. line markers showing tested/untested lines, code coverage per file in the project tree). I can't seem to get this to work with the Karma runner. I have a coverage configuration, and it creates a coverage report at the specified location, but it doesn't seem like Webstorm picks this up and uses it to add the information to the UI.

Should this work, and is it me doing something wrong (perhaps use a different coverage reporter?), or this is not yet working?

Also, trying to run my coverage config with "Run with Coverage" results in this error:
Karma coverage hasn't been initialized in 10000 ms

I'm using Webstorm version 130.1630 and Karma version 0.10.2

Remove the Results column

Find a way to move the timing info from the third column into the first column and remove the third column that repeats most of the info from the first column and only adds timing information.

This will allow more space for the logged output which is way more interesting than the timing info.

Testing

The karma-intellij plugin relies on tons of Karma internals and it's very difficult to not break it. We need some e2e test, that would run a simple project in WebStorm.

@segrey do you have any framework/helpers for testing webstorm that we could take leverage ? I'd really like to get to the point where we have CI build, that starts real webstorm and runs a Karma test, because Karma is now on auto-release (patch versions) - if the Travis build passes it gets released twice a week and this would help us a lot from breaking people.

The patch release should not contain any breaking change (in the stable release), but really this plugin depends on so many internals, that it's pretty much impossible to not break it...

karma config is parsed twice

When Karma server is started by IDE, karma config is parsed twice.
The first parsing is done here:

var config = cfg.parseConfig(ideCfg.getConfigFile(), {});

Why is the first parsing needed?

  1. It's needed to extract an array of plugins specified in karma.conf.js, add intellij karma plugin to them and pass the result array as a part of cli options to server.start(cliOptions)
  2. It's needed to pass parsed karma.conf.js to IDE. At the moment IDE uses basePath config part when starting Karma tests debugging (for remote mappings).

The second parsing is done as expected in karma/lib/server.js.

It'd be much appreciated if Karma core is changed in such a way to make it possible to reduce config parsing count.
Thanks.

Better icons for test results

The tree view on the left, I think just simple circles with a little border would be better:

  • passed test - green (without "OK")
  • failed test - red
  • skipped test - gray

The colors and style are just super quick suggestion, feel free to find something better...

Of course, this is not that high priority...

Coverage Summary: null when >1 browsers attached

If karma.conf.js includes more then one browser, it seems to have issues reporting coverage back to PyCharm/IDE or something.

"Show code coverage data"-window at least says coverage summary: null if multiple browsers attached. Testing with only one browser seems to fix the issue.

Tested with latest pycharm eap, 130.1764

Expected results: to not bail on coverage results when multiple browsers is attached.

From the /tmp/karma-intellij-coverage-.tmp//lcov.info it looks like one of the files always get blank for some odd reason...

hide the first two levels in Karma test tree

Now Karma test tree looks like this:

Test Results
|_ karma.conf.js
    |_ Chrome 28.0.1500 (Linux)
          |_<suite name>
                  |_ <spec name>

Root node {{Test Results}} is useless and can be removed.
If there is only one browser captured, the test tree could look like this:

karma.conf.js (Chrome 28.0.1500 (Linux)
|_<suite name>
    |_ <spec name>

If there are more than one browsers captured, the test tree could look like this:

karma.conf.js
|_ Chrome 28.0.1500 (Linux
     |_<suite name>
          |_ <spec name>
|_ Firefox
     |_<suite name>
          |_ <spec name>

fs.mkdtempSync is not a function

Using WebStorm 2017.1
WebStorm 2017.1
Build #WS-171.3780.79, built on March 17, 2017
JRE: 1.8.0_112-release-736-b13 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 8.1 6.3

"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 2017.1\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js" --karmaPackageDir=\node_modules\karma --configFile=\test\karma.webstorm.conf.js
intellij integration: failed to provide custom /debug.html: failed to create custom debug.html: 
[TypeError: fs.mkdtempSync is not a function]
Hash: f4xxxx

How can I tell what version of fs is being used?

Coverage reporter is asking for `lcov.info` file if `coverage` is absent in karma.conf.js reporters

I'm using Intellij Idea + karma plugin to run karma tests.
Namely, I want to run test coverage.

The issue is that when I run a test with coverage Idea asking me for lcov.info:

screen shot 2018-05-15 at 12 19 02

my karma.conf.js is the following:

module.exports = function(config) {
    return {
        // base path, that will be used to resolve files and exclude
        //        basePath: '',


        // frameworks to use
        frameworks: ['jasmine', 'requirejs'],


        // list of files / patterns to load in the browser
        files: [
            //require.config file
            {pattern: 'src/require.config.js'},

            // tests env libraries
            {pattern: 'src/bower_components/jquery/dist/jquery.js'},
            {pattern: 'src/bower_components/jquery-simulate/jquery.simulate.js'},
            {pattern: 'src/bower_components/jasmine-jquery/lib/jasmine-jquery.js'},
            {pattern: 'src/bower_components/sinonjs/sinon.js'},
            {pattern: 'src/bower_components/sinon-ie/sinon-ie.js'},
            {pattern: 'src/bower_components/jasmine-sinon/lib/jasmine-sinon.js'},

            //source files
            {pattern: 'src/**/*.js', included: false},
            {pattern: 'src/**/*.htm', included: false},
            {pattern: 'src/**/*.json', included: false},


            //all related tests files
            {pattern: 'test/tools/testEnvironment.css'},
            {pattern: 'test/tools/custom.matchers.js'},
            {pattern: 'test/tools/jasmine.ext.js'},
            {pattern: 'test/tools/jquery.cookies.js'},
            {pattern: 'test/mock/**/*.js', included: false},

            //tests loader
            'test/test/test-main.js'
        ],


        // list of files to exclude
        exclude: [

        ],


        // test results reporter to use
        // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
        reporters: ['spec', 'junit'],

        preprocessors: {
            // source files, that you wanna generate coverage for
            // do not include tests or libraries
            // (these files will be instrumented by Istanbul)
            'src/!(bower_components)/**/*.js': ['coverage']

        },

        junitReporter: {
            outputFile: 'test/karma-reports/test-results.xml'
        },

        coverageReporter: {
            includeAllSources: true,
            reporters: [
                {
                    type : 'html',
                    dir : 'test/karma-coverage/coverage/html'
                },
                {
                    type : 'cobertura',
                    dir:   'test/karma-coverage/coverage'
                }
            ]
        },

        // web server port
        port: 9876,


        // enable / disable colors in the output (reporters and logs)
        colors: true,


        // level of logging
        // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
        logLevel: config.LOG_ERROR,


        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: false,


        // Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera (has to be installed with `npm install karma-opera-launcher`)
        // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
        // - PhantomJS
        // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
        browsers: ["PhantomJS"],

        // If browser does not capture in given timeout [ms], kill it
        captureTimeout: 60000,
        browserNoActivityTimeout: 1000000,


        // Continuous Integration mode
        // if true, it capture browsers, run tests and exit
        //singleRun: true,

        plugins: [
            "karma-jasmine",
            "karma-phantomjs-launcher",
            "karma-chrome-launcher",
            "karma-coverage",
            "karma-junit-reporter",
            "karma-spec-reporter",
            "karma-jasmine-html-reporter",
            "karma-requirejs"
        ]
    };
};

if I'm adding coverage reporter manually it becomes working ok:

        reporters: ['spec', 'junit', 'coverage'],

        coverageReporter: {
            includeAllSources: true,
            reporters: [
                {
                    type : 'html',
                    dir : 'test/karma-coverage/coverage/html'
                },
                {
                    type : 'cobertura',
                    dir:   'test/karma-coverage/coverage'
                },
                {
                    type: 'lcov',
                    dir:   'test/karma-coverage/coverage/lcov'
                }
            ]
        }

however i do not want to have 'coverage' in my reporters by default - it slows down tests.

The solution is to add coverage reporter in intellijCoverageReporter.js, see my pull request

Better reporting of skipped specs

A typical workflow is to run only a subset of specs (using iit/ddescribe with Jasmine).

Current output is not what we want:
webstorm-iit

  • remove the "Test skipped" log msg in the right
  • the overal count should display "1 of 1709" (it can also show "1708 skipped" - that's what karma reporter does)
  • the tree view (on the left) should auto expand the specs that were actually run (currently it's useless, as I have to click through and find the one that I executed).
  • the icon for skipped spec/suite (in the tree view on the left) is lame ;-), how about something gray ?

Maybe we could offer "hide skipped" (in the same way there's "hide passed").

Unable to debug

I'm in a team that use the Intellij karma plugin to run unit tests. We use a shared karma.conf.js which others in my team are able to use to run and debug unit tests. However, I am unable to debug and run unit tests. When I attempt to debug unit tests, I see two tabs ("Test Run" and "Karma Server"), but I am missing two tabs that my colleagues see ("Debugger" and "Scripts").

It looks my setup is misconfigured- has anyone got any clues?

image

Add support for karma-cljs-test

I'm using karma-cljs-test to run ClojureScript tests in IntelliJ. Things are working pretty well, but scroll to source doesn't seem to be working. I'm guessing that tests need to report some extra metadata for IntelliJ to use. I'm happy to help add support, but can someone point me in the right direction of what metadata needs to be reported?

Close karma when closing the project

I open a project, run karma tests. I switch to a different project (close the current one). Karma still keeps running in the background, including the capture browser.

Dump logs are not associated with tests

If I have two tests, one of which fails and I put

dump('hello'`)

into both tests then when I select the failed test, I see the stacktrace for the failure but not the dump output.

if I go higher up in the test hierarchy and select "Chrome ...", it shows me the stack trace and both dump logs.

it would be great if selecting a test would show me all the logs associated with this test and only logs from this test.

Karma Server not starting

Hello,

I create the karma.conf.js and it uses the karma plugin from webstorm, but when I try to run it, I get this error all the time:

/usr/local/bin/node /Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js --karmaPackageDir=/usr/local/lib/node_modules/karma --configFile=/Users/arber/Sites/portal/tests/karma.conf.js

/Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js:10
server.start(cliOptions);
^
TypeError: Object function (cliOptions, done) {
EventEmitter.call(this)

setupLogger(cliOptions.logLevel, cliOptions.colors)

this.log = logger.create()

var config = cfg.parseConfig(cliOptions.configFile, cliOptions)

var modules = [{
helper: ['value', helper],
logger: ['value', logger],
done: ['value', done || process.exit],
emitter: ['value', this],
launcher: ['type', Launcher],
config: ['value', config],
preprocess: ['factory', preprocessor.createPreprocessor],
fileList: ['type', FileList],
webServer: ['factory', ws.create],
socketServer: ['factory', createSocketIoServer],
executor: ['type', Executor],
// TODO(vojta): remove
customFileHandlers: ['value', []],
// TODO(vojta): remove, once karma-dart does not rely on it
customScriptTypes: ['value', []],
reporter: ['factory', reporter.createReporters],
capturedBrowsers: ['type', BrowserCollection],
args: ['value', {}],
timer: ['value', {setTimeout: setTimeout, clearTimeout: clearTimeout}]
}]

// Load the plugins
modules = modules.concat(plugin.resolve(config.plugins))

this._injector = new di.Injector(modules)
} has no method 'start'
at Object. (/Applications/WebStorm.app/Contents/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js:10:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Process finished with exit code 8

I'm using Webstorm 10 with karma plugin version: 141.1550

Thanks.

Display better "time" information

Karma has two times: 1/ total time (total time - since the first file changed/trigering the tes run to the very last result) 2/ net time (sum of all specs; pure browser execution).

With WebStorm, there's pretty much another time - the total from the point of WebStorm view. (since it started the test run, to finish).

What is the time displayed in the UI ?

I think having the net execution can be helpful.

LOW PRIORITY

logger missing "create()" method

I'm getting the following error trying to run a coverage test in WebStorm 7:

/usr/local/bin/node /Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js --karmaPackageDir=/Users/alord/Projects/openpd/node_modules/karma --configFile=/Users/alord/Projects/openpd/src/test/openpd/karma.conf.js --coverageTempDir=/private/var/folders/zm/r6h2v0n961l5c6jx_swvpq340000gp/T/karma-intellij-coverage-1043838342133174871.tmp
WARN [reporter]: Can not load "intellijCoverage_33e284dac2b015a9da50d767dc3fa58a"!
  TypeError: Object #<Object> has no method 'create'
    at IntellijCoverageReporter.CoverageReporter (/Users/alord/Projects/openpd/node_modules/karma-coverage/lib/reporter.js:41:20)
    at IntellijCoverageReporter.init (/Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijCoverageReporter.js:93:25)
    at new IntellijCoverageReporter (/Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijCoverageReporter.js:44:10)
    at invoke (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at Array.instantiate [as 0] (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:59:20)
    at get (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at /Users/alord/Projects/openpd/node_modules/karma/lib/reporter.js:50:75
    at Array.forEach (native)
    at createReporters (/Users/alord/Projects/openpd/node_modules/karma/lib/reporter.js:38:9)
    at Array.invoke [as 0] (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at get (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at get (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:54:19)
    at /Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:71:14
    at Array.map (native)
    at invoke (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:70:31)
    at createWebServer (/Users/alord/Projects/openpd/node_modules/karma/lib/web-server.js:53:21)
    at Array.invoke [as 0] (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:75:15)
    at get (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:48:43)
    at /Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:71:14
    at Array.map (native)
    at invoke (/Users/alord/Projects/openpd/node_modules/karma/node_modules/di/lib/injector.js:70:31)
    at Object.exports.start (/Users/alord/Projects/openpd/node_modules/karma/lib/server.js:206:12)
    at Object.<anonymous> (/Applications/WebStorm.app/plugins/js-karma/js_reporter/karma-intellij/lib/intellijServer.js:4:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
INFO [karma]: Karma v0.10.8 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 32.0.1700 (Mac OS X 10.9.1)]: Connected on socket W3_5YaGcAiUDxe4mu8eJ

The furthest back I was able to trace it to was line 75 of injector.js, so I don't know where the logger is assigned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.