Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 使用Chutzpah,其中WebPack将ts编译为单个js文件_Visual Studio_Typescript_Webpack_Chutzpah - Fatal编程技术网

Visual studio 使用Chutzpah,其中WebPack将ts编译为单个js文件

Visual studio 使用Chutzpah,其中WebPack将ts编译为单个js文件,visual-studio,typescript,webpack,chutzpah,Visual Studio,Typescript,Webpack,Chutzpah,我已经用Angular模板创建了一个默认的ASP.NET核心Web应用程序(文件->新建项目->Visual C->.NET核心)。这是VS 2017中100%开箱即用的模板,带有.NET Core 2,我没有做任何更改。ClientApp/app/components/counter/counter.components.spec.ts中已经有一个JS测试文件,我想让Chutzpah在这个项目上工作 我不熟悉.NETCore和Webpack(但不是Chutzpah或jasmine测试)。据我所

我已经用Angular模板创建了一个默认的ASP.NET核心Web应用程序(文件->新建项目->Visual C->.NET核心)。这是VS 2017中100%开箱即用的模板,带有.NET Core 2,我没有做任何更改。ClientApp/app/components/counter/counter.components.spec.ts中已经有一个JS测试文件,我想让Chutzpah在这个项目上工作

我不熟悉.NETCore和Webpack(但不是Chutzpah或jasmine测试)。据我所知,在这个项目中,webpack通过typescript文件在./wwwroot/dist/main-client.js处生成一个捆绑的js文件,它是在运行时而不是编译时完成的。老实说,我很困惑是什么导致webpack在运行时启动

似乎几乎所有关于使用Chutzpah的常见示例和问题都涉及一个项目,其中每个.ts文件在同一文件夹中都有一个相应的.js编译文件。但是这个默认项目没有做到这一点;它在运行时将TS编译为JS,并在一个无缝操作中捆绑所有内容。我喜欢这种设置,真的不想摆脱它;它很干净

但就我的一生而言,我甚至无法猜测如何编写一个chutzpah.json配置文件,在这种情况下可以工作从哪里开始?我已经看过了,这个默认配置和示例所做的有太多的不同,我不知道如何前进

以下是测试文件component.spec.ts的内容,仅供参考

/// <reference path="../../../../node_modules/@types/jasmine/index.d.ts" />
import { assert } from 'chai';
import { CounterComponent } from './counter.component';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';

let fixture: ComponentFixture<CounterComponent>;

describe('Counter component', () => {
    beforeEach(() => {
        TestBed.configureTestingModule({ declarations: [CounterComponent] });
        fixture = TestBed.createComponent(CounterComponent);
        fixture.detectChanges();
    });

    it('should display a title', async(() => {
        const titleText = fixture.nativeElement.querySelector('h1').textContent;
        expect(titleText).toEqual('Counter');
    }));

    it('should start with count 0, then increments by 1 when clicked', async(() => {
        const countElement = fixture.nativeElement.querySelector('strong');
        expect(countElement.textContent).toEqual('0');

        const incrementButton = fixture.nativeElement.querySelector('button');
        incrementButton.click();
        fixture.detectChanges();
        expect(countElement.textContent).toEqual('1');
    }));
});
//
从'chai'导入{assert};
从“./counter.component”导入{CounterComponent};
从“@angular/core/testing”导入{TestBed,async,ComponentFixture};
let夹具:组件夹具;
描述('计数器组件',()=>{
在每个之前(()=>{
configureTestingModule({声明:[计数器组件]});
fixture=TestBed.createComponent(计数器组件);
fixture.detectChanges();
});
它('应该显示标题'),异步(()=>{
const titleText=fixture.nativeElement.querySelector('h1').textContent;
expect(titleText).toEqual('Counter');
}));
它('应以计数0开始,然后单击时递增1',异步(()=>{
const countElement=fixture.nativeElement.querySelector('strong');
expect(countElement.textContent).toEqual('0');
const incrementButton=fixture.nativeElement.querySelector('button');
递增按钮。单击();
fixture.detectChanges();
expect(countElement.textContent).toEqual('1');
}));
});

你能找到解决方案吗?@alekkowalczyk令人沮丧的是,没有。我有点离开了,但并没有停止对解决方案的渴望。不过,VisualStudio中最新的Angular模板在编译时根本不将.ts编译为.js;编译在运行时或多或少地按角度进行,因此这使事情变得非常有趣。