Skip to content
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
1 change: 1 addition & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class Store {
constructor (options = {}) {
assert(Vue, `must call Vue.use(Vuex) before creating a store instance.`)
assert(typeof Promise !== 'undefined', `vuex requires a Promise polyfill in this browser.`)
assert(this instanceof Store, `Store must be called with the new operator.`)

const {
plugins = [],
Expand Down
6 changes: 6 additions & 0 deletions test/unit/store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ describe('Store', () => {
})
})

it('asserts the call with the new operator', () => {
expect(() => {
Vuex.Store({})
}).toThrowError(/Store must be called with the new operator/)
})

it('should accept state as function', () => {
const store = new Vuex.Store({
state: () => ({
Expand Down