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 { AspNetProcess, AspNetCoreEnviroment, defaultUrl, publishProjectSync } from './util/aspnet';
import { getValue, getCssPropertyValue } from './util/webdriverio'; import { getValue, getCssPropertyValue } from './util/webdriverio';
// First, generate a new project using the locally-built generator-aspnetcore-spa // Currently we test both 'csproj' and 'project.json' project types. Eventually we'll only need csproj.
// Do this outside the Mocha fixture, otherwise Mocha will time out ['csproj', 'projectjson'].forEach(toolingType => {
const appDir = path.resolve(__dirname, '../generated/angular'); // First, generate a new project using the locally-built generator-aspnetcore-spa
const publishedAppDir = path.resolve(appDir, './bin/Release/published'); // Do this outside the Mocha fixture, otherwise Mocha will time out
if (!process.env.SKIP_PROJECT_GENERATION) { const appDir = path.resolve(__dirname, '../generated/angular', toolingType);
const publishedAppDir = path.resolve(appDir, './bin/Release/published');
if (!process.env.SKIP_PROJECT_GENERATION) {
generateProjectSync(appDir, { generateProjectSync(appDir, {
framework: 'angular-2', framework: 'angular-2',
name: 'Test App', 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 tests: false
}); });
publishProjectSync(appDir, publishedAppDir); publishProjectSync(appDir, publishedAppDir);
} }
function testBasicNavigation() { function testBasicNavigation() {
describe('Basic navigation', () => { describe('Basic navigation', () => {
beforeEach(() => browser.url(defaultUrl)); beforeEach(() => browser.url(defaultUrl));
@@ -46,9 +48,9 @@ function testBasicNavigation() {
expect(getValue(browser.elements('fetchdata table tbody tr')).length).to.eq(5); expect(getValue(browser.elements('fetchdata table tbody tr')).length).to.eq(5);
}); });
}); });
} }
function testHotModuleReplacement() { function testHotModuleReplacement() {
describe('Hot module replacement', () => { describe('Hot module replacement', () => {
beforeEach(() => browser.url(defaultUrl)); beforeEach(() => browser.url(defaultUrl));
@@ -86,16 +88,19 @@ function testHotModuleReplacement() {
} }
}); });
}); });
} }
// Now launch dotnet and use selenium to perform tests // Now launch dotnet and use selenium to perform tests
describe('Angular template: dev mode', () => { describe('Angular template: dev mode', () => {
AspNetProcess.RunInMochaContext(appDir, AspNetCoreEnviroment.development); AspNetProcess.RunInMochaContext(appDir, AspNetCoreEnviroment.development);
testBasicNavigation(); testBasicNavigation();
testHotModuleReplacement(); testHotModuleReplacement();
}); });
describe('Angular template: production mode', () => { describe('Angular template: production mode', () => {
AspNetProcess.RunInMochaContext(publishedAppDir, AspNetCoreEnviroment.production, 'angular.dll'); // 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(); testBasicNavigation();
});
}); });