-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Handle own core config migration logic
- Loading branch information
Showing
4 changed files
with
96 additions
and
4 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
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 |
---|---|---|
@@ -1 +1,9 @@ | ||
// Register core config options | ||
const { default: PercyConfig } = require('@percy/config'); | ||
const CoreConfig = require('./config'); | ||
|
||
PercyConfig.addSchema(CoreConfig.schema); | ||
PercyConfig.addMigration(CoreConfig.migration); | ||
|
||
// Export the Percy class with commonjs compatibility | ||
module.exports = require('./percy').default; |
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,63 @@ | ||
import expect from 'expect'; | ||
import { migration } from '../../src/config'; | ||
|
||
describe('Unit / Config', () => { | ||
let migrate; | ||
let set = (key, value) => (migrate[key] = value); | ||
|
||
beforeEach(() => { | ||
migrate = {}; | ||
}); | ||
|
||
it('migrates v1 config', () => { | ||
migration({ | ||
version: 1, | ||
snapshot: { | ||
widths: [1000] | ||
}, | ||
agent: { | ||
assetDiscovery: { | ||
requestHeaders: { foo: 'bar' }, | ||
allowedHostnames: ['allowed'], | ||
networkIdleTimeout: 150, | ||
pagePoolSizeMin: 1, | ||
pagePoolSizeMax: 5, | ||
cacheResponses: false | ||
} | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({ | ||
snapshot: { widths: [1000] }, | ||
'snapshot.requestHeaders': { foo: 'bar' }, | ||
'discovery.allowedHostnames': ['allowed'], | ||
'discovery.networkIdleTimeout': 150, | ||
'discovery.concurrency': 5, | ||
'discovery.disableCache': true | ||
}); | ||
}); | ||
|
||
it('only migrates own config options', () => { | ||
migration({ | ||
version: 1, | ||
otherOptions: { | ||
baseUrl: 'base-url', | ||
snapshotFiles: '*.html', | ||
ignoreFiles: '*.htm' | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
|
||
it('does not migrate when not needed', () => { | ||
migration({ | ||
version: 2, | ||
discovery: { | ||
allowedHostnames: ['allowed'] | ||
} | ||
}, set); | ||
|
||
expect(migrate).toEqual({}); | ||
}); | ||
}); |