import * as fs from 'fs'; import * as path from 'path'; import { expect } from 'chai'; import { generateProjectSync } from './util/yeoman'; import { AspNetProcess, AspNetCoreEnviroment, defaultUrl, publishProjectSync } from './util/aspnet'; import { getValue, getCssPropertyValue } from './util/webdriverio'; // First, generate a new project using the locally-built generator-aspnetcore-spa // Do this outside the Mocha fixture, otherwise Mocha will time out const appDir = path.resolve(__dirname, '../generated/angular'); const publishedAppDir = path.resolve(appDir, './bin/Release/published'); if (!process.env.SKIP_PROJECT_GENERATION) { generateProjectSync(appDir, { framework: 'angular', name: 'Test App', tests: true }); publishProjectSync(appDir, publishedAppDir); } function testBasicNavigation() { describe('Basic navigation', () => { beforeEach(() => browser.url(defaultUrl)); it('should initially display the home page', () => { expect(browser.getText('h1')).to.eq('Hello, world!'); expect(browser.getText('li a[href="https://angular.io/"]')).to.eq('Angular'); }); it('should be able to show the counter page', () => { browser.click('a[href="/counter"]'); expect(browser.getText('h1')).to.eq('Counter'); // Test clicking the 'increment' button expect(browser.getText('counter strong')).to.eq('0'); browser.click('counter button'); expect(browser.getText('counter strong')).to.eq('1'); }); it('should be able to show the fetchdata page', () => { browser.click('a[href="/fetch-data"]'); expect(browser.getText('h1')).to.eq('Weather forecast'); browser.waitForExist('fetchdata table'); expect(getValue(browser.elements('fetchdata table tbody tr')).length).to.eq(5); }); }); } function testHotModuleReplacement() { describe('Hot module replacement', () => { beforeEach(() => browser.url(defaultUrl)); it('should update when HTML is changed', () => { expect(browser.getText('h1')).to.eq('Hello, world!'); const filePath = path.resolve(appDir, './ClientApp/app/components/home/home.component.html'); const origFileContents = fs.readFileSync(filePath, 'utf8'); try { const newFileContents = origFileContents.replace('