diff --git a/packages/create-instance/create-component-stubs.js b/packages/create-instance/create-component-stubs.js
index 51a9deb58..ddc99cca3 100644
--- a/packages/create-instance/create-component-stubs.js
+++ b/packages/create-instance/create-component-stubs.js
@@ -111,7 +111,17 @@ export function createStubFromComponent(
const slots = context ? context.slots() : this._renderProxy.$slots
- const children = Object.entries(slots).map(([slotName, slotChildren]) =>
+ // ensure consistent ordering of slots (default first, then alphabetical)
+ const sortedSlotEntries = Object.entries(slots)
+ sortedSlotEntries.sort(([slotNameA], [slotNameB]) =>
+ slotNameA === 'default'
+ ? -1
+ : slotNameB === 'default'
+ ? 1
+ : slotNameA.localeCompare(slotNameB)
+ )
+
+ const children = sortedSlotEntries.map(([slotName, slotChildren]) =>
slotName === 'default'
? slotChildren
: h('template-stub', { attrs: { slot: slotName } }, slotChildren)
diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js
index d8aecfb65..63485dc4c 100644
--- a/test/specs/shallow-mount.spec.js
+++ b/test/specs/shallow-mount.spec.js
@@ -92,10 +92,10 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
expect(wrapper.html()).to.equal(
'\n' +
' default slot content\n' +
- ' Hello\n' +
' \n' +
' \n' +
' \n' +
+ ' Hello\n' +
''
)
})
@@ -121,10 +121,10 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
expect(wrapper.html()).to.equal(
'\n' +
' default slot content\n' +
- ' Hello\n' +
' \n' +
' \n' +
' \n' +
+ ' Hello\n' +
''
)
})