未捕获错误:模块分析失败:g:\demo\my-ng2-admin\my-ng2-admin\my-ng2-admin\node_module\awesome-typescript-loader\dist\entry.js?{“configfilename”:“g:\demo\my-ng2-admin\my-ng2-admin\my-ng2-admin\src\tsconfig.json”}!g:\demo\my-ng2-admin\my-ng2-admin\my-ng2-admin\node_module\angular2-template-loader\index.js!
You may need an appropriate loader to handle this file type.
| var de;
| var el;
| beforeEach(function () __awaiter(this, void 0, void 0, function* () {
| testing_1.TestBed.configureTestingModule({
| declarations: [testBanner_component_1.testBanner]
和更多详细信息
//webpack.test.js
var webpack = require('webpack');
var helpers = require('./config/helpers');
module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
entry: {
},
// entry: {
//
// 'polyfills': './src/polyfills.browser.ts',
// 'vendor': './src/vendor.browser.ts',
// 'main': './src/main.browser.ts'
//
// },
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: { configFileName: helpers.root('src', 'tsconfig.json') }
}, 'angular2-template-loader'
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
loader: 'null-loader'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
loader: 'null-loader'
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
loader: 'raw-loader'
}
]
},
plugins: [
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
)
]
}
//karma.conf.js
var webpackConfig = require('./webpack.test');
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: [
{pattern: './karma-shim.js', watched: false}
],
// 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: {
'./karma-shim.js': ['webpack']
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'errors-only'
},
webpackServer: {
noInfo: true
},
plugins:[
'karma-jasmine',
'karma-chrome-launcher',
//'karma-sourcemap-loader',
require("karma-webpack")
],
proxies:{
//http://localhost:3000/#/pages/strategys/strategytables
"/app/": "base/src/app"
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// 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
})
}
//karma-shim.js
Error.stackTraceLimit = Infinity;
require('core-js/es6');
require('core-js/es7/reflect');
require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/proxy');
require('zone.js/dist/sync-test');
require('zone.js/dist/jasmine-patch');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
var appContext = require.context('./src', true, /\.spec\.ts/);
appContext.keys().forEach(appContext);
var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');
testing.TestBed.initTestEnvironment(browser.BrowserDynamicTestingModule,
browser.platformBrowserDynamicTesting());
//testBanner.component.spec.ts
import {} from "@types/jasmine";
import {ComponentFixture, TestBed, ComponentFixtureAutoDetect,async} from"@angular/core/testing";
import { By } from "@angular/platform-browser";
import { DebugElement } from "@angular/core";
import { testBanner } from "./testBanner.component";
describe('bannerComponent test',()=> {
var comp:testBanner;
var fixture:ComponentFixture<testBanner>;
var de: DebugElement;
var el: HTMLElement;
beforeEach(async()=>{
TestBed.configureTestingModule({
declarations:[testBanner],
}).compileComponents();
beforeEach(()=>{
fixture = TestBed.createComponent(testBanner);
comp = fixture.componentInstance;
de = fixture.debugElement.query(By.css('h1'));
el = de.nativeElement;
});
});
it('should display original title', () => {
fixture.detectChanges();
expect(el.textContent).toContain(comp.title);
});
it('should display a different test title', () => {
comp.title = 'Test Title';
fixture.detectChanges();
expect(el.textContent).toContain('Test Title');
});
});
这对遇到这个问题的人很有帮助。
您需要在webpack.test.js
(webpack配置文件)中添加以下更改:
尝试如下所示更新加载程序'awesome-typescript-loader':
{
loader: 'awesome-typescript-loader?presets[]=es2017',
options: { configFileName: helpers.root('src', 'tsconfig.json') }
}
我刚刚开始使用一个升级的模板将我的aspdotnet core Aurelia项目升级到3.0,该模板是我用来创建项目的模板。 我把我的文件(在以前的项目工作)到这个新版本,我已经结束了一堆错误,从webpack的第一个是在标题中概述。 网页包也已升级。这是我收到的第一个错误。。 发现了与此相同的问题,结果发现我没有替身,所以是另外一个问题。。 我还检查了这个标题非常相似的问题,但我相信webpa
我得到下面的错误,我不明白为什么我认为应该有一些与巴贝尔。我使用web开发服务器和babel。它在反应。 我的Webconfig文件如下所示: 我的package.json文件如下所示: 我错过了什么?这与path.resolve有关吗?
我正面临下面的错误。我尝试了所有的解决方案在其他文章中提到的相同的问题。但没有运气。请帮帮忙。 下面是我的档案。 package.json webpack.conf.js 应用程序JS index.js
我用Webpack创建了我的项目,并在开发中使用了Vue.js,但是我不能注入
我正在学习反应,并试图用webpack创建一个样板。我遵循了一个教程,在他的视频作品的一切,但在我的电脑上,我得到的错误消息,一个适当的加载器需要处理一个特定的文件类型。 这就是错误产生的文件 以下是错误消息: ./src/index.js 5:16模块解析中出错失败:意外标记(5:16)您可能需要适当的加载程序来处理此文件类型。|从“./components/App”导入应用程序| ReactD
组件如下所示。是我正在使用链接的本地依赖项 uilib/index.css如下所示