Skip to content

Commit

Permalink
Merge pull request #437 from live-codes/improve-tests
Browse files Browse the repository at this point in the history
Improve tests
  • Loading branch information
hatemhosny authored Sep 16, 2023
2 parents f00f3da + ec8778f commit 091de6b
Show file tree
Hide file tree
Showing 14 changed files with 164 additions and 73 deletions.
8 changes: 8 additions & 0 deletions docs/docs/configuration/configuration-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ Default: `false`

If `true`, the project is automatically saved on code change, after time [delay](#delay).

### `autotest`

Type: [`boolean`](../api/interfaces/Config.md#autotest)

Default: `false`

If `true`, the project is watched for code changes which trigger tests to auto-run.

### `delay`

Type: [`number`](../api/interfaces/Config.md#delay)
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/features/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ describe('test global', () => {

## Supported Jest features

- Jest globals: `expect`, `test`, `it`, `describe`, `beforeAll`, `afterAll`, `beforeEach`, `afterEach`
- Jest function mocks: `jest.fn`, `jest.spyOn`, `jest.clearAllMocks`, `jest.resetAllMocks`
- [Jest globals](https://jestjs.io/docs/api): `expect`, `test`, `xtest`, `it`, `fit`, `xit`, `describe`, `fdescribe`, `xdescribe`, `beforeAll`, `afterAll`, `beforeEach`, `afterEach`
- Jest function mocks: `jest.fn`, `jest.mocked`, `jest.replaceProperty`, `jest.spyOn`

These can be directly used in the test editor, without the need for any imports.
Autocomplete is available in Monaco editor for Jest API.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/sdk/js-ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ createPlayground('#container').then((playground) => {
const testsWatcher = playground.watch('tests', ({ results }) => {
// this will run when tests run
results.forEach((testResult) => {
console.log('status:', testResult.status); // "pass" or "fail"
console.log('status:', testResult.status); // "pass", "fail" or "skip"
console.log(testResult.errors); // array of errors as strings
});
});
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const getContentConfig = (config: Config | ContentConfig): ContentConfig
export const getUserConfig = (config: Config | UserConfig): UserConfig => ({
autoupdate: config.autoupdate,
autosave: config.autosave,
autotest: config.autotest,
delay: config.delay,
formatOnsave: config.formatOnsave,
recoverUnsaved: config.recoverUnsaved,
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/config/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const defaultConfig: Config = {
tags: [],
autoupdate: true,
autosave: false,
autotest: false,
delay: 1500,
formatOnsave: false,
mode: 'full',
Expand Down
1 change: 1 addition & 0 deletions src/livecodes/config/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const validateConfig = (config: Partial<Config>): Partial<Config> => {
...(is(config.tags, 'array', 'string') ? { tags: removeDuplicates(config.tags) } : {}),
...(is(config.autoupdate, 'boolean') ? { autoupdate: config.autoupdate } : {}),
...(is(config.autosave, 'boolean') ? { autosave: config.autosave } : {}),
...(is(config.autotest, 'boolean') ? { autotest: config.autotest } : {}),
...(is(config.delay, 'number') ? { delay: Number(config.delay) } : {}),
...(is(config.formatOnsave, 'boolean') ? { formatOnsave: config.formatOnsave } : {}),
...(includes(modes, config.mode) ? { mode: config.mode } : {}),
Expand Down
Loading

0 comments on commit 091de6b

Please sign in to comment.