Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load-plugins test and snapshot update after #4490 #5907

Merged
merged 1 commit into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "d41d8cd98f00b204e9800998ecf8427e",
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand Down Expand Up @@ -188,6 +188,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand All @@ -199,7 +200,7 @@ Array [
},
"resolve": "",
"ssrAPIs": Array [],
"version": "d41d8cd98f00b204e9800998ecf8427e",
"version": "1.0.0",
},
Object {
"browserAPIs": Array [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
const loadPlugins = require(`../index`)

describe(`Load plugins`, () => {
/**
* Replace the resolve path and version string.
* Resolve path will vary depending on platform.
* Version can be updated (we use external plugin in default config).
* Both will cause snapshots to differ.
*/
const replaceFieldsThatCanVary = plugins => plugins.map(plugin => {
return {
...plugin,
resolve: ``,
version: `1.0.0`,
}
})

it(`Load plugins for a site`, async () => {
let plugins = await loadPlugins({ plugins: [] })

// Delete the resolve path as that varies depending
// on platform so will cause snapshots to differ.
plugins = plugins.map(plugin => {
return {
...plugin,
resolve: ``,
}
})
plugins = replaceFieldsThatCanVary(plugins)

expect(plugins).toMatchSnapshot()
})
Expand All @@ -27,14 +34,7 @@ describe(`Load plugins`, () => {

let plugins = await loadPlugins(config)

// Delete the resolve path as that varies depending
// on platform so will cause snapshots to differ.
plugins = plugins.map(plugin => {
return {
...plugin,
resolve: ``,
}
})
plugins = replaceFieldsThatCanVary(plugins)

expect(plugins).toMatchSnapshot()
})
Expand Down