-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
Tests have been seperated into different commands.
- Loading branch information
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// A test to ensure that the server builds and opens the home url. | ||
|
||
describe('Basic Home', () => { | ||
it('can navigate to the home page', async () => { | ||
await page.goto(__SERVER__.home); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Retrieve the browser name from the environment | ||
*/ | ||
export const getBrowserName = (): SupportedBrowserName => process.env.REMIRROR_E2E_BROWSER || 'chromium'; | ||
|
||
/** | ||
* Prefix the browser name to the passed in string | ||
*/ | ||
export const prefixBrowserName = (...value: string[]) => | ||
`${getBrowserName()}-${process.platform}-${__SERVER__.name}-${value.join('-')}`; | ||
|
||
/** | ||
* Declare the globals used throughout tests | ||
*/ | ||
declare global { | ||
const __DEV__: boolean; | ||
const __TEST__: boolean; | ||
/** | ||
* Identifies whether this is an e2e test | ||
*/ | ||
const __E2E__: boolean; | ||
|
||
/** | ||
* Lists the servers running for end to end test. | ||
* Currently this supports ['next', 'storybook', 'docz'] | ||
*/ | ||
const __SERVER__: { | ||
config: { | ||
command: string; | ||
port: number; | ||
usedPortAction: 'ask' | 'error' | 'ignore' | 'kill'; | ||
launchTimeout: number; | ||
}; | ||
regex: string; | ||
urls: Record<RemirrorTestEditors, { empty: string; content: string }>; | ||
home: string; | ||
name: string; | ||
}; | ||
|
||
namespace NodeJS { | ||
interface ProcessEnv { | ||
REMIRROR_E2E_BROWSER?: SupportedBrowserName; | ||
REMIRROR_E2E_SERVER?: string; | ||
REMIRROR_E2E_DEBUG?: string; | ||
REMIRROR_E2E_DOCKER?: string; | ||
/** | ||
* When set only run the most basic of tests. | ||
*/ | ||
REMIRROR_E2E_BASIC?: string; | ||
} | ||
} | ||
|
||
type RemirrorTestServers = 'storybook' | 'next' | 'docz' | 'razzle'; | ||
type RemirrorTestEditors = 'twitter' | 'wysiwyg' | 'epic'; | ||
type SupportedBrowserName = 'firefox' | 'chromium'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
const { | ||
REMIRROR_E2E_BROWSER = 'chromium', | ||
REMIRROR_E2E_SERVER = 'storybook', | ||
REMIRROR_E2E_BASIC, | ||
} = process.env; | ||
|
||
const basicRegex = 'basic\\.e2e\\.test\\.ts$'; | ||
|
||
const noSSRRegex = REMIRROR_E2E_BASIC | ||
? basicRegex | ||
: `.*\\.(e2e|${REMIRROR_E2E_SERVER})\\.test\\.ts$`; | ||
|
||
const allTestRegex = REMIRROR_E2E_BASIC | ||
? basicRegex | ||
: REMIRROR_E2E_BROWSER === 'firefox' | ||
? noSSRRegex | ||
: `.*\\.(e2e|ssr|${REMIRROR_E2E_SERVER})\\.test\\.ts$`; | ||
|
||
const servers = (exports.servers = { | ||
next: { | ||
server: { | ||
command: 'cd examples/with-next && yarn build && yarn start -p 3030', | ||
port: 3030, | ||
usedPortAction: 'kill', | ||
launchTimeout: 120000, | ||
}, | ||
regex: allTestRegex, | ||
home: 'http://localhost:3030', | ||
}, | ||
storybook: { | ||
server: { | ||
command: 'yarn start-storybook -p 3030 -c support/storybook --quiet --ci', | ||
port: 3030, | ||
usedPortAction: 'kill', | ||
launchTimeout: 120000, | ||
}, | ||
regex: noSSRRegex, | ||
home: 'http://localhost:3030', | ||
}, | ||
docz: { | ||
server: { | ||
command: 'cd docs && yarn docz dev --debug -p 3030', | ||
port: 3030, | ||
usedPortAction: 'kill', | ||
launchTimeout: 120000, | ||
}, | ||
regex: noSSRRegex, | ||
home: 'http://localhost:3030', | ||
}, | ||
razzle: { | ||
server: { | ||
command: 'cd examples/with-razzle && PORT=3030 yarn start', | ||
port: 3030, | ||
usedPortAction: 'kill', | ||
launchTimeout: 120000, | ||
}, | ||
regex: allTestRegex, | ||
home: 'http://localhost:3030', | ||
}, | ||
}); | ||
|
||
const editors = (exports.editors = { | ||
twitter: { | ||
storybook: { | ||
empty: 'http://localhost:3030/iframe.html?id=twitter-editor--basic', | ||
content: 'http://localhost:3030/iframe.html?id=twitter-editor--with-content', | ||
}, | ||
next: { | ||
empty: 'http://localhost:3030/editor/twitter', | ||
content: 'http://localhost:3030/editor/twitter/content', | ||
}, | ||
docz: { | ||
empty: 'http://localhost:3030/showcase/twitter', | ||
content: '', | ||
}, | ||
razzle: { | ||
empty: 'http://localhost:3030/editors/twitter', | ||
content: 'http://localhost:3030/editors/twitter/content', | ||
}, | ||
}, | ||
wysiwyg: { | ||
storybook: { | ||
empty: 'http://localhost:3030/iframe.html?id=wysiwyg-editor--basic', | ||
content: 'http://localhost:3030/iframe.html?id=wysiwyg-editor--with-content', | ||
}, | ||
next: { | ||
empty: 'http://localhost:3030/editor/wysiwyg', | ||
content: 'http://localhost:3030/editor/wysiwyg/content', | ||
}, | ||
docz: { | ||
empty: 'http://localhost:3030/showcase/wysiwyg', | ||
content: '', | ||
}, | ||
razzle: { | ||
empty: 'http://localhost:3030/editors/wysiwyg', | ||
content: 'http://localhost:3030/editors/wysiwyg/content', | ||
}, | ||
}, | ||
}); | ||
|
||
exports.server = { | ||
...servers[REMIRROR_E2E_SERVER], | ||
name: REMIRROR_E2E_SERVER, | ||
urls: Object.keys(editors).reduce((acc, key) => { | ||
return { | ||
...acc, | ||
[key]: editors[key][REMIRROR_E2E_SERVER], | ||
}; | ||
}, {}), | ||
}; |