karma test runner not running any tests

前端 未结 3 1956
慢半拍i
慢半拍i 2021-02-07 07:42

I\'m using karma with jasmine and followed online guide by installing using

npm install --save-dev karma

and other necessities

i ran

相关标签:
3条回答
  • 2021-02-07 08:17

    Following configuration works for me -

     reporters: ['progress', 'kjhtml'],
            port: 9876,
            colors: true,
            logLevel: config.LOG_INFO, // config.LOG_DEBUG,
            autoWatch: true,
            browsers: ['ChromeNS'],
            singleRun: false,
            customLaunchers: {
                ChromeHeadlessNS: {
                    base: 'ChromeHeadless',
                    flags: ['--no-sandbox', '--disable-gpu']
                },
                ChromeNS: {
                    base: 'Chrome',
                    flags: ['--no-sandbox', '--disable-gpu']
                }
            }
    
    0 讨论(0)
  • 2021-02-07 08:22

    Under karma.config.js, set either singleRun or autoWatch to true. In your case both of them are set to false, hence karma is not running the tests.

    singleRun: If true, it captures browsers, runs tests and exits with 0 exit code (if all tests passed) or 1 exit code (if any test failed).

    singleRun: true
    

    autoWatch: Enable or disable watching files and executing the tests whenever one of these files changes. Incase you want to watch your files.

    autoWatch: true
    
    0 讨论(0)
  • 2021-02-07 08:26

    Simple but sometimes overlooked cause: ensure you don't have syntax or compilation errors.

    If running a Karma test for JavaScript via your IDE, you may have a syntax error which doesn't appear when you run your tests. This leads to Karma issuing the message "no tests were found".

    I ran it under WebStorm; the error appeared under the "Karma Server" tab, while the "No tests were found" message appeared under "Test Run" (both tabs under "Run" or "Debug" tool window).

    0 讨论(0)
提交回复
热议问题