Programing

오류 : __karma __. start 메소드를 구현하는 일부 어댑터를 포함해야합니다.

crosscheck 2020. 9. 22. 07:32
반응형

오류 : __karma __. start 메소드를 구현하는 일부 어댑터를 포함해야합니다.


내 프로젝트 중 하나에 단위 테스트를 추가하려고합니다.

지금까지 카르마를 설치 및 구성하고 재스민을 설치했습니다. test/폴더에 테스트 파일이 하나 있습니다.

Karma 서버가 시작되고 브라우저 페이지가 준비되었지만 karma run다음과 같이 실패합니다.

$ karma run karma-conf.js 
[2014-06-14 15:19:11.046] [DEBUG] config - Loading config /foo/test/karma-conf.js
Waiting for previous execution...
Chrome 35.0.1916 (Linux) ERROR
  You need to include some adapter that implements __karma__.start method!

이 오류 메시지는 Google에 적합하지 않습니다.

이것이 명백한 것입니까, 아니면 더 많은 정보를 제공해야합니까?


이것은 매우 일반적인 오류 인 것 같지만 제 경우 문제는 karma start올바른 폴더에서 실행하지 않았 거나 구성을 변경 한 후 다시 시작하지 않은 것입니다.

이 질문을 열어두고이 오류 메시지를 경험하는 다른 사람들을위한 리소스가되기를 바랍니다.


karma 구성 파일의 이름을 지정 karma.conf.js하면 간단히 입력 할 수 있습니다 karma start.

그렇지 않으면 파일 이름을 지정하십시오 karma start karmafile.js

(나는 올바른 디렉토리에 있었지만 파일 이름을 지정하지 않았습니다.)


karma runkarma-conf.js가있는 폴더에서 사용자 또는 다른 기능 을 실행해야합니다 .


제 경우에는 파일 이름을 karma.conf.js 로 변경 한 다음 karma start를 수행해야했습니다.


karma.conf.js파일 코드 형식에 문제가 있습니다.

files: [
    // Modules
    ,"client/bower_components/angular/angular.min.js"
    ,"client/bower_components/angular-mocks/angular-mocks.js"
    // App
    ,"client/app/app.module.js"
    // Test
    // ,"test/**/*.spec.js"
],

files배열 의 추가 쉼표로 인해 다음 오류가 발생합니다.

You need to include some adapter that implements __karma__.start method!

내 karma.conf.js가있는 경로에서 karma start 명령을 실행하지 않았습니다 . 해당 폴더로 전환하고 동일한 명령을 실행했습니다. 그게 다야


Angular.js 코드베이스에서 사양을 실행하는 동안이 문제에 직면했습니다. 나는 npm install karma-jasmine -g이것을 작동시키기 위해 달려야 했다.


"karma start"를 입력하는 경우 현재 폴더에 karma.conf.js 파일이 있어야합니다. 또는 "karma start /path/karma.conf.js"

"karma init /path/karma.conf.js"로 새 karmar.conf.js를 생성 해보십시오.


프로젝트에서 Babel 6을 사용 중이고 babelrc 파일을 추가하는 것을 잊었 기 때문에 동일한 오류가 발생했습니다. 이것이 도움이 될 경우를 대비하여 공유하십시오.


필자의 경우 메시지는 사실 매우 설명 적이었습니다. 어댑터 (제 경우 Jasmine)를 구성 파일에 추가하는 것을 잊었습니다. 그러므로:

module.exports = function(config) {
  config.set({
      browsers: ['Chrome'],
      singleRun: true,
      frameworks: ['jasmine'],
      files: [
          // ... files ...
      ],
      // other configs
    });
};

"my.conf.js"파일에는 코드를 테스트하는 데 사용할 모든 정보가 포함되어 있으므로 구성해야합니다.

작성해야 할 모든 것은 다음과 같습니다.

구성 파일은 karma init를 사용하여 생성 할 수 있습니다.

$ karma init my.conf.js

어떤 테스트 프레임 워크를 사용 하시겠습니까? 가능한 옵션을 나열하려면 탭을 누르십시오. 다음 질문으로 이동하려면 입력하세요.

재스민 속

Do you want to use Require.js? This will add Require.js plugin. Press tab to list possible options. Enter to move to the next question.

no

Do you want to capture a browser automatically? Press tab to list possible options. Enter empty string to move to the next question.

Chrome

What is the location of your source and test files? You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js". Press Enter to move to the next question.

*.js test/**/*.js

Should any of the files included by the previous patterns be excluded? You can use glob patterns, eg. "**/*.swp".

Press Enter to move to the next question.

Do you want Karma to watch all the files and run the tests on change? Press tab to list possible options.

yes

Config file generated at "/Users/vojta/Code/karma/my.conf.js".


In my case, I was applying by mistake the commonjs preprocessor to the karma-* modules and the adapter.js from karma-chrome and karma-firefox was broken this way.

Unfortunately, this is a very generic error.


I must add that in my case karma was giving me the error because I had [square] brackets in the name of one of the parent folders.


Tt's complaining about the adapter which is probably jasmine or mocha. Either the adapter is missing, either is not setup correctly, either it's an outdated or buggy version of the adapter.

In my case I had an old version of mocha 2.5.3 which was not compatible with karma 1+. I updated the mocha dependency to the latest version available 3.2.0 and the problem solved.


While working on numerous vaguely described errors, I tried setting basePath: '../', After correcting other errors (like missing commas that were described as object content errors) the last change back to basePath: '', got karma to work. karma's error statements need a lot of work. It is not simple to get it going.


FWIW - sourcing the file path of karma.conf.js worked for me locally, but not on my jenkins builder. I have zero clue why this is the case, but on jenkins it was throwing this error unless the karma.conf.js file was in the root directory where the karma command was given. I'm using rails and running the js specs through a rake task. Code is below which might be helpful for some.

https://gist.github.com/daino3/a39486ff8bfc1668e923


The issue in my case was that karma didn't pick up any files. Fixing it in karma.conf.js solved the issue.


Same issue happened to me, and it was due to an outdated module.

Running npm update solved it.


In my case, it was not karma-related at all! I run karma from gulp, with ES6/babel, and there was actually a code syntax error, flagged by a babel error above my karma:

ERROR [preprocessor.babel]: xxx.js: Unexpected token (19:83)

I fixed that in my src and karma was happy again.


I had the same issue. My browser would open but on my terminal it threw the following error

30 08 2017 11:19:28.272:INFO [Chrome 58.0.3029 (Linux 0.0.0)]: Connected `enter code here`on socket 5sSs6E5KmpUVRp6LAAAB with id 93886631
Chrome 58.0.3029 (Linux 0.0.0) ERRORSome of your tests did a full page reload!

I checked my karma.conf.js file. In the framework array , i had included jasmine and requirejs. But i had only installed karma-jasmine.Removing requireJS and rerunning the karma start worked!


I've been struggling with this too. What I came up to is that this error occurs because one of the following reasons

My problem was that my config file was named karma.config.js instead of karma.conf.js.

If you've installed the test adapter but it still doesn't work, try running karma init and go through the guided config setup.


In my case, the configuration file name was different. So, running the command specifying the conf file solved my issue.

>> karma start unit-tests.conf.js
No captured browser, open http://localhost:9876/
...

And for 'PhantomJS', opening the link specified(localhost:9876) in the browser executes the test cases.

Hope it helps. :)

EDIT 1: My Karma Config File

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      './node_modules/angular/angular.js',
      './node_modules/angular-ui-router/release/angular-ui-router.js',
      './node_modules/angular-mocks/angular-mocks.js',
      './app/services/users/users.js',
      './app/app.js',
      './app/services/users/users.spec.js'
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['spec'],


    // 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_INFO,


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


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}

You will have to specify the directory of karma.config.js when you run start karma.

Try

karma start karma.config.js


I received this error because I required the same dependency twice!

Removing the duplicate file dependency removed the error for me. Circled in blue below.

enter image description here


I had a bad 'files' configuration in my karma.conf.js

files: ['**/*.js'],

this caught up all the files in node_modules/ including those of the karma-jasmine plugin, as it was seen as sourde files it wasn't loaded on startup. Changing to

files: [
        'src/*.js',
        'spec/*.js'
    ],

solved the problem in my case

참고URL : https://stackoverflow.com/questions/24220888/error-you-need-to-include-some-adapter-that-implements-karma-start-method

반응형