2017-01-10 5 views
3

Aurelia 테스트에서 뷰를로드하는 중에 문제가 발생했습니다. 내가로드 할 수있어 테스트보다 실행 한 후Aurelia 사용자 정의 요소 테스트에서 뷰를로드 할 수 없습니다.

proxies: { 
    '/base/jspm_packages/': '/base/wwwroot/jspm_packages/' 
} 

- .. 샘플 테스트 코드 아래에 내가 프락시로 테스트를 실행하는 카르마를 사용하고

import {StageComponent} from 'aurelia-testing'; 
 
import {bootstrap} from 'aurelia-bootstrapper'; 
 

 
describe('MyComponent',() => { 
 
    let component; 
 

 
    beforeEach(() => { 
 
    component = StageComponent 
 
     .withResources('src/common/my-component') 
 
     .inView('<my-component first-name.bind="firstName"></my-component>') 
 
     .boundTo({ firstName: 'Bob' }); 
 
    }); 
 

 
    it('should render first name', done => { 
 
    component.create(bootstrap).then(() => { 
 
     const nameElement = document.querySelector('.firstName'); 
 
     expect(nameElement.innerHTML).toBe('Bob'); 
 
     done(); 
 
    }).catch(e => { console.log(e.toString()) }); 
 
    }); 
 

 
    afterEach(() => { 
 
    component.dispose(); 
 
    }); 
 
});

을 참조하십시오 뷰 모델을 열었지만 다음 오류가있는보기를로드하지 못했습니다. -

LOG: 'Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:9876/base/src/common/my-component.html Error: XHR error (404 Not Found) loading http://localhost:9876/base/src/common/my-component.html Error loading http://localhost:9876/base/src/common/my-component.html!http://localhost:9876/base/jspm_packages/github/systemjs/[email protected] Error loading http://localhost:9876/base/src/common/my-component.html!template-registry-entry '

사전에 도와 주셔서 감사합니다!

UPDATE -> Karma.conf.js 파일

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: ['jspm', 'jasmine'], 
 

 
    jspm: { 
 
     // Edit this to your needs 
 
     loadFiles: ['test/unit/setup.js', 'test/unit/**/*.js'], 
 
     serveFiles: ['src/**/*.js'], 
 
     paths: { 
 
     '*': 'src/*', 
 
     'test/*': 'test/*', 
 
     'github:*': 'jspm_packages/github/*', 
 
     'npm:*': 'jspm_packages/npm/*' 
 
     } 
 
    }, 
 

 
    // list of files/patterns to load in the browser 
 
    files: [], 
 
    proxies: { 
 
     '/base/jspm_packages/': '/base/wwwroot/jspm_packages/' 
 
    }, 
 

 
    // 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/**/*.js': ['babel'], 
 
     'src/**/*.js': ['babel', 'coverage'] 
 
    }, 
 
    'babelPreprocessor': { 
 
     options: { 
 
     sourceMap: 'inline', 
 
     presets: ['es2015-loose', 'stage-1'], 
 
     plugins: [ 
 
      'syntax-flow', 
 
      'transform-decorators-legacy', 
 
      'transform-flow-strip-types' 
 
     ] 
 
     } 
 
    }, 
 

 
    // test results reporter to use 
 
    // possible values: 'dots', 'progress' 
 
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter 
 
    reporters: ['progress', '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_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 
 
    }) 
 
}

+0

이것은 아마도 * 귀하의 카르마 설정과 관련된 문제 일 것입니다 - 귀하의'karma.conf.js' 파일을 공유 할 수 있습니까? –

+0

@PWKad - karma.conf.js로 질문 업데이트 –

답변

3

그것은 수 있습니다이 라인이 :

serveFiles: ['src/**/*.js'], 

실제로이 있어야한다 :

serveFiles: ['src/**/*.js', 'src/**/*.html'] 

일반적으로 html은 구성 요소의 j와 번들로 묶이지 만이 경우에는 html을 직접 제공합니다.

+1

고맙습니다. 그것은 나를 위해 일했습니다! –