Run tests against both csproj and project.json-style projects. Assumes relevant dotnet SDKs are installed locally.

This commit is contained in:
SteveSandersonMS
2016-12-15 17:17:04 +00:00
parent f34eb582ad
commit 4fd19b4293

View File

@@ -5,21 +5,23 @@ 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) {
// Currently we test both 'csproj' and 'project.json' project types. Eventually we'll only need csproj.
['csproj', 'projectjson'].forEach(toolingType => {
// 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', toolingType);
const publishedAppDir = path.resolve(appDir, './bin/Release/published');
if (!process.env.SKIP_PROJECT_GENERATION) {
generateProjectSync(appDir, {
framework: 'angular-2',
name: 'Test App',
sdkVersion: '1.0.0-preview2-1-003177',
sdkVersion: toolingType === 'projectjson' ? '1.0.0-preview2-1-003177' : '1.0.0-preview3-004056',
tests: false
});
publishProjectSync(appDir, publishedAppDir);
}
}
function testBasicNavigation() {
function testBasicNavigation() {
describe('Basic navigation', () => {
beforeEach(() => browser.url(defaultUrl));
@@ -46,9 +48,9 @@ function testBasicNavigation() {
expect(getValue(browser.elements('fetchdata table tbody tr')).length).to.eq(5);
});
});
}
}
function testHotModuleReplacement() {
function testHotModuleReplacement() {
describe('Hot module replacement', () => {
beforeEach(() => browser.url(defaultUrl));
@@ -86,16 +88,19 @@ function testHotModuleReplacement() {
}
});
});
}
}
// Now launch dotnet and use selenium to perform tests
describe('Angular template: dev mode', () => {
// Now launch dotnet and use selenium to perform tests
describe('Angular template: dev mode', () => {
AspNetProcess.RunInMochaContext(appDir, AspNetCoreEnviroment.development);
testBasicNavigation();
testHotModuleReplacement();
});
});
describe('Angular template: production mode', () => {
AspNetProcess.RunInMochaContext(publishedAppDir, AspNetCoreEnviroment.production, 'angular.dll');
describe('Angular template: production mode', () => {
// csproj tooling takes the assembly name from <name>.csproj, whereas project.json takes it from the directory name
const assemblyName = toolingType === 'csproj' ? 'TestApp.dll' : 'projectjson.dll';
AspNetProcess.RunInMochaContext(publishedAppDir, AspNetCoreEnviroment.production, assemblyName);
testBasicNavigation();
});
});