Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions packages/runner/src/__tests__/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Options', () => {
describe('extensionDir', () => {
it('should default to the current working directory', async () => {
const actual = await resolveRunOptions({});

expect(actual).toMatchObject<Partial<ResolvedRunOptions>>({
extensionDir: process.cwd(),
});
Expand All @@ -34,40 +35,50 @@ describe('Options', () => {
const actual = await resolveRunOptions({
extensionDir: './path/to/extension',
});

expect(actual).toMatchObject<Partial<ResolvedRunOptions>>({
extensionDir: resolve(process.cwd(), './path/to/extension'),
});
});

it('should use absolute paths as-is', async () => {
const actual = await resolveRunOptions({
extensionDir: '/abs/path/to/extension2',
});

expect(actual).toMatchObject<Partial<ResolvedRunOptions>>({
extensionDir: resolve('/abs/path/to/extension2'),
});
});
});

describe('target', () => {
it('should be "chrome" by default', async () => {
const actual = await resolveRunOptions({
extensionDir: 'path/to/extension',
});
const actual = await resolveRunOptions({});

expect(actual).toMatchObject<Partial<ResolvedRunOptions>>({
target: 'chrome',
});
});

it('should be what is passed in', async () => {
const actual = await resolveRunOptions({
extensionDir: 'path/to/extension',
target: 'custom',
browserBinaries: {
custom: '/path/to/custom/browser',
},
});

expect(actual).toMatchObject<Partial<ResolvedRunOptions>>({
target: 'custom',
});
});

it('should throw an error if the target binary could not be found', async () => {
const actual = resolveRunOptions({
extensionDir: 'path/to/extension',
target: 'custom',
});

await expect(actual).rejects.toThrow('Could not find "custom" binary.');
});
});
Expand All @@ -83,7 +94,6 @@ describe('Options', () => {
? 'C:\\path\\to\\custom\\browser.exe'
: path;
const actual = await resolveRunOptions({
extensionDir: 'path/to/extension',
target: 'custom',
browserBinaries: {
custom: path,
Expand All @@ -98,9 +108,11 @@ describe('Options', () => {
describe('chromiumArgs', () => {
it('should log a warning when --user-data-dir is passed in', async () => {
const warnSpy = vi.spyOn(console, 'warn');

await resolveRunOptions({
chromiumArgs: ['--user-data-dir=some/custom/path'],
});

expect(warnSpy).toBeCalledTimes(1);
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining(
Expand All @@ -111,9 +123,11 @@ describe('Options', () => {

it('should log a warning when --remote-debugging-port is passed in', async () => {
const warnSpy = vi.spyOn(console, 'warn');

await resolveRunOptions({
chromiumArgs: ['--remote-debugging-port=9222'],
});

expect(warnSpy).toBeCalledTimes(1);
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining(
Expand All @@ -126,6 +140,7 @@ describe('Options', () => {
const actual = await resolveRunOptions({
chromiumArgs: ['--window-size=1920,1080'],
});

expect(actual.chromiumArgs).toEqual([
// Defaults
'--disable-features=Translate,OptimizationHints,MediaRouter,DialMediaRouteProvider,CalculateNativeWinOcclusion,InterestFeedContentSuggestions,CertificateTransparencyComponentUpdater,AutofillServerCommunication,PrivacySandboxSettings4',
Expand Down Expand Up @@ -161,9 +176,11 @@ describe('Options', () => {
describe('firefoxArgs', () => {
it('should log a warning when --profile is passed in', async () => {
const warnSpy = vi.spyOn(console, 'warn');

await resolveRunOptions({
firefoxArgs: ['--profile=some/custom/path'],
});

expect(warnSpy).toBeCalledTimes(1);
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining('Custom Firefox --profile argument ignored'),
Expand All @@ -172,9 +189,11 @@ describe('Options', () => {

it('should log a warning when --remote-debugging-port is passed in', async () => {
const warnSpy = vi.spyOn(console, 'warn');

await resolveRunOptions({
firefoxArgs: ['--remote-debugging-port=9222'],
});

expect(warnSpy).toBeCalledTimes(1);
expect(warnSpy).toHaveBeenCalledWith(
expect.stringContaining(
Expand All @@ -187,6 +206,7 @@ describe('Options', () => {
const actual = await resolveRunOptions({
firefoxArgs: ['--window-size=1920,1080'],
});

expect(actual.firefoxArgs).toEqual([
// Defaults
'--new-instance',
Expand Down
Loading