-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(init): add reference to mono schema (#2162)
* Deliver a big schema as artifact. This will include the core schema as well as schemas from all known plugins. It is delivered here: https://unpkg.com/@stryker-mutator/core/schema/stryker-schema.json * Add a `$schema` reference to the "mono-schema". A schema file that contains all valid config from all main-supported stryker plugins. This will allow users to explore the different options of our plugin.
- Loading branch information
Showing
16 changed files
with
294 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,5 @@ package-lock.json | |
.DS_Store | ||
tsconfig.*.tsbuildinfo | ||
src-generated | ||
packages/core/schema | ||
__filterSpecs.js |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "mono-schema", | ||
"description": "A test for the 'mono-schema'. A json schema that got merged from all the objects and put into @stryker-mutator/core/schema", | ||
"scripts": { | ||
"test": "mocha --require \"ts-node/register\" verify/verify.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"$schema": "../../../node_modules/@stryker-mutator/core/schema/stryker-schema.json", | ||
"allowConsoleColors": true, | ||
"babel": { | ||
"options": { | ||
"compact": "invalid" | ||
} | ||
}, | ||
"jest": { | ||
"config": "" | ||
}, | ||
"wct": { | ||
"configFile": {} | ||
}, | ||
"jasmineConfigFile": false, | ||
"webpack": { | ||
"configFile": [] | ||
}, | ||
"karma": { | ||
"ngConfig": { | ||
"testArguments": "--test test" | ||
} | ||
}, | ||
"tsconfig": { | ||
"moduleResolution": "invalid" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"$schema": "../../../node_modules/@stryker-mutator/core/schema/stryker-schema.json", | ||
"allowConsoleColors": true, | ||
"babel": { | ||
"options": { | ||
"compact": "auto" | ||
} | ||
}, | ||
"jest": { | ||
"config": {} | ||
}, | ||
"wct": { | ||
"configFile": "a file" | ||
}, | ||
"jasmineConfigFile": "A file", | ||
"webpack": { | ||
"configFile": "webpack.config.js" | ||
}, | ||
"karma": { | ||
"ngConfig": { | ||
"testArguments": { "test": "test" } | ||
} | ||
}, | ||
"tsconfig": { | ||
"moduleResolution": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { expect } from 'chai'; | ||
import valid from '../test/valid.json'; | ||
import invalid from '../test/invalid.json'; | ||
import monoSchema from '@stryker-mutator/core/schema/stryker-schema.json'; | ||
import Ajv from 'ajv'; | ||
import Axios from 'axios'; | ||
import { beforeEach } from 'mocha'; | ||
|
||
const ajv = new Ajv({ | ||
async: true, | ||
allErrors: true, | ||
loadSchema: async (url) => { | ||
const content = await Axios.get(url); | ||
delete content.data.$schema; | ||
return content.data; | ||
}, | ||
}); | ||
|
||
describe('The Stryker meta schema', () => { | ||
let validator: Ajv.ValidateFunction; | ||
|
||
beforeEach(async () => { | ||
validator = await ajv.compileAsync(monoSchema); | ||
}); | ||
|
||
it('should validate a valid schema', async () => { | ||
expect(validator(valid), ajv.errorsText(validator.errors)).true; | ||
}); | ||
|
||
it('should invalidate a invalid schema', async () => { | ||
expect(validator(invalid)).false; | ||
expect(validator.errors).deep.eq(expectedErrors); | ||
}); | ||
|
||
const expectedErrors = [ | ||
{ | ||
keyword: 'enum', | ||
dataPath: '.babel.options.compact', | ||
schemaPath: 'http://json.schemastore.org/babelrc/properties/compact/enum', | ||
params: { | ||
allowedValues: ['auto', true, false], | ||
}, | ||
message: 'should be equal to one of the allowed values', | ||
}, | ||
{ | ||
keyword: 'type', | ||
dataPath: '.jasmineConfigFile', | ||
schemaPath: '#/properties/jasmineConfigFile/type', | ||
params: { | ||
type: 'string', | ||
}, | ||
message: 'should be string', | ||
}, | ||
{ | ||
keyword: 'type', | ||
dataPath: '.jest.config', | ||
schemaPath: '#/properties/jest/properties/config/type', | ||
params: { | ||
type: 'object', | ||
}, | ||
message: 'should be object', | ||
}, | ||
{ | ||
keyword: 'type', | ||
dataPath: '.karma.ngConfig.testArguments', | ||
schemaPath: '#/definitions/karmaNgConfigOptions/properties/testArguments/type', | ||
params: { | ||
type: 'object', | ||
}, | ||
message: 'should be object', | ||
}, | ||
{ | ||
keyword: 'enum', | ||
dataPath: '.tsconfig.moduleResolution', | ||
schemaPath: | ||
'http://json.schemastore.org/tsconfig#/definitions/compilerOptionsDefinition/properties/compilerOptions/properties/moduleResolution/anyOf/0/enum', | ||
params: { | ||
allowedValues: ['Classic', 'Node'], | ||
}, | ||
message: 'should be equal to one of the allowed values', | ||
}, | ||
{ | ||
keyword: 'pattern', | ||
dataPath: '.tsconfig.moduleResolution', | ||
schemaPath: | ||
'http://json.schemastore.org/tsconfig#/definitions/compilerOptionsDefinition/properties/compilerOptions/properties/moduleResolution/anyOf/1/pattern', | ||
params: { | ||
pattern: '^(([Nn]ode)|([Cc]lassic))$', | ||
}, | ||
message: 'should match pattern "^(([Nn]ode)|([Cc]lassic))$"', | ||
}, | ||
{ | ||
keyword: 'anyOf', | ||
dataPath: '.tsconfig.moduleResolution', | ||
schemaPath: | ||
'http://json.schemastore.org/tsconfig#/definitions/compilerOptionsDefinition/properties/compilerOptions/properties/moduleResolution/anyOf', | ||
params: {}, | ||
message: 'should match some schema in anyOf', | ||
}, | ||
{ | ||
keyword: 'type', | ||
dataPath: '.wct.configFile', | ||
schemaPath: '#/properties/wct/properties/configFile/type', | ||
params: { | ||
type: 'string', | ||
}, | ||
message: 'should be string', | ||
}, | ||
{ | ||
keyword: 'type', | ||
dataPath: '.webpack.configFile', | ||
schemaPath: '#/properties/webpack/properties/configFile/type', | ||
params: { | ||
type: 'string', | ||
}, | ||
message: 'should be string', | ||
}, | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
!src/** | ||
src/**/*.map | ||
src/**/*.ts | ||
!schema/*.json | ||
!src/**/*.d.ts | ||
!readme.md | ||
!LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.