@web/test-runner-core
Advanced tools
Comparing version 0.6.18 to 0.6.19
# @web/test-runner-core | ||
## 0.6.19 | ||
### Patch Changes | ||
- 432f090: expose browser name from BrowserLauncher | ||
- 5b36825: prevent debug sessions from interferring with regular test sessions | ||
## 0.6.18 | ||
@@ -4,0 +11,0 @@ |
import { CoverageMapData } from 'istanbul-lib-coverage'; | ||
import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig'; | ||
import { TestSession } from '../test-session/TestSession'; | ||
export interface Viewport { | ||
@@ -14,2 +13,6 @@ width: number; | ||
/** | ||
* A human friendly name to identify this browser. Doesn't need to be unique. | ||
*/ | ||
name: string; | ||
/** | ||
* One time startup for the browser launcher. Called when the test runner | ||
@@ -19,3 +22,3 @@ * starts. | ||
*/ | ||
start(config: TestRunnerCoreConfig, testFiles: string[]): Promise<string>; | ||
start(config: TestRunnerCoreConfig, testFiles: string[]): void | Promise<void>; | ||
/** | ||
@@ -34,3 +37,3 @@ * One time teardown for the browser launcher. Called when the test runner | ||
*/ | ||
startSession(session: TestSession, url: string): Promise<void>; | ||
startSession(sessionId: string, url: string): Promise<void>; | ||
/** | ||
@@ -41,3 +44,3 @@ * Returns whether this session is currently active. If it is active, stopSession | ||
*/ | ||
isActive(session: TestSession): boolean; | ||
isActive(sessionId: string): boolean; | ||
/** | ||
@@ -49,3 +52,3 @@ * Stops a single test session. There is no mandatory action to be taken here. | ||
*/ | ||
stopSession(session: TestSession): SessionResult | Promise<SessionResult>; | ||
stopSession(sessionId: string): SessionResult | Promise<SessionResult>; | ||
/** | ||
@@ -57,3 +60,3 @@ * Starts a debug session. This should start a session like startSession, but | ||
*/ | ||
startDebugSession(session: TestSession, url: string): Promise<void>; | ||
startDebugSession(sessionId: string, url: string): Promise<void>; | ||
/** | ||
@@ -63,4 +66,4 @@ * Sets the viewport. Not all browser implementations support this. | ||
*/ | ||
setViewport(session: TestSession, viewport: Viewport): void | Promise<void>; | ||
setViewport(sessionId: string, viewport: Viewport): void | Promise<void>; | ||
} | ||
//# sourceMappingURL=BrowserLauncher.d.ts.map |
@@ -27,3 +27,3 @@ import { BrowserLauncher } from '../browser-launcher/BrowserLauncher.js'; | ||
port: number; | ||
browsers: BrowserLauncher | BrowserLauncher[]; | ||
browsers: BrowserLauncher[]; | ||
testFramework?: TestFramework; | ||
@@ -30,0 +30,0 @@ logger: Logger; |
@@ -12,2 +12,4 @@ import * as constants from './browser-launcher/constants'; | ||
export { TestSession, TestResultError, TestResult } from './test-session/TestSession'; | ||
export { DebugTestSession } from './test-session/DebugTestSession'; | ||
export { BasicTestSession } from './test-session/BasicTestSession'; | ||
export { TestSessionManager } from './test-session/TestSessionManager'; | ||
@@ -14,0 +16,0 @@ export { TestSessionStatus, SESSION_STATUS } from './test-session/TestSessionStatus'; |
@@ -10,3 +10,2 @@ import { TestSession } from '../test-session/TestSession'; | ||
testFiles: string[]; | ||
browserNames: string[]; | ||
startTime: number; | ||
@@ -13,0 +12,0 @@ } |
import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig'; | ||
import { TestSession } from '../test-session/TestSession'; | ||
import { BasicTestSession } from '../test-session/BasicTestSession'; | ||
export declare function toBrowserPath(filePath: string): string; | ||
export declare function createSessionUrl(config: TestRunnerCoreConfig, session: TestSession, debug: boolean): string; | ||
export declare function createSessionUrl(config: TestRunnerCoreConfig, session: BasicTestSession, debug: boolean): string; | ||
//# sourceMappingURL=createSessionUrl.d.ts.map |
import { TestSession } from '../test-session/TestSession'; | ||
import { BrowserLauncher } from '../browser-launcher/BrowserLauncher'; | ||
export declare function createTestSessions(browserNameForLauncher: Map<BrowserLauncher, string>, testFiles: string[]): TestSession[]; | ||
export declare function createTestSessions(browsers: BrowserLauncher[], testFiles: string[]): TestSession[]; | ||
//# sourceMappingURL=createTestSessions.d.ts.map |
@@ -6,11 +6,11 @@ "use strict"; | ||
const TestSessionStatus_1 = require("../test-session/TestSessionStatus"); | ||
function createTestSessions(browserNameForLauncher, testFiles) { | ||
function createTestSessions(browsers, testFiles) { | ||
const sessions = []; | ||
for (const testFile of testFiles) { | ||
for (const [browserLauncher, browserName] of browserNameForLauncher) { | ||
for (const browser of browsers) { | ||
const session = { | ||
id: uuid_1.v4(), | ||
debug: false, | ||
testRun: -1, | ||
browserName, | ||
browserLauncher, | ||
browser, | ||
status: TestSessionStatus_1.SESSION_STATUS.SCHEDULED, | ||
@@ -17,0 +17,0 @@ testFile, |
@@ -21,3 +21,2 @@ import { TestRunnerCoreConfig } from '../config/TestRunnerCoreConfig'; | ||
sessions: TestSessionManager; | ||
browserNames: string[]; | ||
testFiles: string[]; | ||
@@ -31,3 +30,2 @@ startTime: number; | ||
focusedTestFile: string | undefined; | ||
private browserLaunchers; | ||
private scheduler; | ||
@@ -34,0 +32,0 @@ private pendingSessions; |
@@ -12,2 +12,3 @@ "use strict"; | ||
const createSessionUrl_1 = require("./createSessionUrl"); | ||
const createDebugSessions_1 = require("./createDebugSessions"); | ||
class TestRunner extends EventEmitter_1.EventEmitter { | ||
@@ -17,3 +18,2 @@ constructor(config, testFiles) { | ||
this.sessions = new TestSessionManager_1.TestSessionManager(); | ||
this.browserNames = []; | ||
this.startTime = -1; | ||
@@ -28,3 +28,2 @@ this.testRun = -1; | ||
this.testFiles = testFiles.map(f => path_1.resolve(f)); | ||
this.browserLaunchers = Array.isArray(config.browsers) ? config.browsers : [config.browsers]; | ||
this.scheduler = new TestScheduler_1.TestScheduler(config, this.sessions); | ||
@@ -44,13 +43,7 @@ this.sessions.on('session-status-updated', session => { | ||
this.startTime = Date.now(); | ||
const browserNameForLauncher = new Map(); | ||
this.browserNames = []; | ||
for (const launcher of this.browserLaunchers) { | ||
const name = await launcher.start(this.config, this.testFiles); | ||
this.browserNames.push(name); | ||
browserNameForLauncher.set(launcher, name); | ||
for (const browser of this.config.browsers) { | ||
await browser.start(this.config, this.testFiles); | ||
} | ||
const createdSessions = createTestSessions_1.createTestSessions(browserNameForLauncher, this.testFiles); | ||
for (const session of createdSessions) { | ||
this.sessions.add(session); | ||
} | ||
const createdSessions = createTestSessions_1.createTestSessions(this.config.browsers, this.testFiles); | ||
this.sessions.add(...createdSessions); | ||
await this.config.server.start({ | ||
@@ -111,3 +104,3 @@ config: this.config, | ||
const stopActions = []; | ||
for (const browser of this.browserLaunchers) { | ||
for (const browser of this.config.browsers) { | ||
stopActions.push(browser.stop().catch(error => { | ||
@@ -121,5 +114,7 @@ console.error(error); | ||
startDebugBrowser(testFile) { | ||
for (const session of this.sessions.forTestFile(testFile)) { | ||
session.browserLauncher | ||
.startDebugSession(session, createSessionUrl_1.createSessionUrl(this.config, session, true)) | ||
const debugSessions = createDebugSessions_1.createDebugSessions(this.config.browsers, testFile); | ||
this.sessions.addDebug(...debugSessions); | ||
for (const session of debugSessions) { | ||
session.browser | ||
.startDebugSession(session.id, createSessionUrl_1.createSessionUrl(this.config, session, true)) | ||
.catch(error => { | ||
@@ -126,0 +121,0 @@ console.error(error); |
@@ -72,3 +72,3 @@ "use strict"; | ||
try { | ||
await updatedSession.browserLauncher.startSession(updatedSession, createSessionUrl_1.createSessionUrl(this.config, updatedSession, false)); | ||
await updatedSession.browser.startSession(updatedSession.id, createSessionUrl_1.createSessionUrl(this.config, updatedSession, false)); | ||
// when the browser started, wait for session to ping back on time | ||
@@ -102,4 +102,4 @@ this.waitForTestsStarted(updatedSession.testRun, updatedSession.id); | ||
try { | ||
if (session.browserLauncher.isActive(session)) { | ||
const { testCoverage, browserLogs } = await session.browserLauncher.stopSession(session); | ||
if (session.browser.isActive(session.id)) { | ||
const { testCoverage, browserLogs } = await session.browser.stopSession(session.id); | ||
updatedSession.testCoverage = testCoverage; | ||
@@ -106,0 +106,0 @@ updatedSession.logs = browserLogs; |
import { CoverageMapData } from 'istanbul-lib-coverage'; | ||
import { TestSessionStatus } from './TestSessionStatus'; | ||
import { BrowserLauncher } from '../browser-launcher/BrowserLauncher'; | ||
import { BasicTestSession } from './BasicTestSession'; | ||
export interface TestResultError { | ||
@@ -15,8 +15,5 @@ message: string; | ||
} | ||
export interface TestSession { | ||
id: string; | ||
export interface TestSession extends BasicTestSession { | ||
debug: false; | ||
testRun: number; | ||
browserLauncher: BrowserLauncher; | ||
browserName: string; | ||
testFile: string; | ||
status: TestSessionStatus; | ||
@@ -23,0 +20,0 @@ passed?: boolean; |
import { TestSession } from './TestSession'; | ||
import { TestSessionStatus } from './TestSessionStatus'; | ||
import { EventEmitter } from '../utils/EventEmitter'; | ||
import { DebugTestSession } from './DebugTestSession'; | ||
interface EventMap { | ||
@@ -10,3 +11,5 @@ 'session-status-updated': TestSession; | ||
private sessionsMap; | ||
add(session: TestSession): void; | ||
private debugSessions; | ||
add(...sessions: TestSession[]): void; | ||
addDebug(...sessions: DebugTestSession[]): void; | ||
updateStatus(session: TestSession, status: TestSessionStatus): void; | ||
@@ -24,4 +27,8 @@ update(session: TestSession): void; | ||
failed(): Generator<TestSession, void, unknown>; | ||
getDebug(id: string): DebugTestSession | undefined; | ||
getAllDebug(): IterableIterator<DebugTestSession>; | ||
setDebug(debugSession: DebugTestSession): void; | ||
removeDebug(id: string): void; | ||
} | ||
export {}; | ||
//# sourceMappingURL=TestSessionManager.d.ts.map |
@@ -18,6 +18,14 @@ "use strict"; | ||
this.sessionsMap = new Map(); | ||
this.debugSessions = new Map(); | ||
} | ||
add(session) { | ||
this.sessionsMap.set(session.id, session); | ||
add(...sessions) { | ||
for (const session of sessions) { | ||
this.sessionsMap.set(session.id, session); | ||
} | ||
} | ||
addDebug(...sessions) { | ||
for (const session of sessions) { | ||
this.debugSessions.set(session.id, session); | ||
} | ||
} | ||
updateStatus(session, status) { | ||
@@ -54,6 +62,6 @@ const updatedSession = Object.assign(Object.assign({}, session), { status }); | ||
forBrowser(...browserNames) { | ||
return this.filtered(s => browserNames.includes(s.browserName)); | ||
return this.filtered(s => browserNames.includes(s.browser.name)); | ||
} | ||
forBrowserAndTestFile(testFile, ...browserNames) { | ||
return this.filtered(s => browserNames.includes(s.browserName) && (!testFile || s.testFile === testFile)); | ||
return this.filtered(s => browserNames.includes(s.browser.name) && (!testFile || s.testFile === testFile)); | ||
} | ||
@@ -66,4 +74,16 @@ passed() { | ||
} | ||
getDebug(id) { | ||
return this.debugSessions.get(id); | ||
} | ||
getAllDebug() { | ||
return this.debugSessions.values(); | ||
} | ||
setDebug(debugSession) { | ||
this.debugSessions.set(debugSession.id, debugSession); | ||
} | ||
removeDebug(id) { | ||
this.debugSessions.delete(id); | ||
} | ||
} | ||
exports.TestSessionManager = TestSessionManager; | ||
//# sourceMappingURL=TestSessionManager.js.map |
{ | ||
"name": "@web/test-runner-core", | ||
"version": "0.6.18", | ||
"version": "0.6.19", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85614
83
1047