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
9 changes: 4 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const buildConfig = require("./jest.base.config")

module.exports = buildConfig(__dirname, {
module.exports = {
coverageDirectory: "<rootDir>/coverage/",
coverageReporters: ["lcov", "text"],
projects: ["<rootDir>/packages/*/jest.config.js", "<rootDir>/packages/*/jest.config-*.js"]
// collectCoverageFrom: ["<rootDir>/packages/*/src/**/*.{ts,tsx}"]
})
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"packages/*"
],
"resolutions": {
"jest": "^29.5.0",
"jest": "^30.3.0",
"typescript": "^5.9.2",
"recast": "^0.23.1"
},
Expand Down Expand Up @@ -36,7 +36,7 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^16.1.0",
"@types/jest": "^26.0.15",
"@types/jest": "^30.0.0",
"@types/node": "18",
"@types/prop-types": "^15.5.2",
"@types/react": "^18.0.0",
Expand All @@ -50,8 +50,8 @@
"husky": "^4.2.5",
"import-size": "^1.0.2",
"iterall": "^1.3.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest": "^30.3.0",
"jest-environment-jsdom": "^30.3.0",
"jest-mock-console": "^1.0.1",
"lerna": "^3.22.1",
"lint-staged": "^10.1.7",
Expand All @@ -66,7 +66,7 @@
"react-test-renderer": "^18.0.0",
"serializr": "^2.0.3",
"tape": "^5.0.1",
"ts-jest": "^29.0.5",
"ts-jest": "^29.4.6",
"tsdx": "^0.14.1",
"typescript": "^5.9.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`changing state in render should fail 1`] = `
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`printDebugValue 1`] = `
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`base useAsObservableSource should work with <Observer> 1`] = `
[MockFunction] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`base useLocalStore should work 1`] = `
[MockFunction] {
Expand Down
6 changes: 3 additions & 3 deletions packages/mobx-react-lite/__tests__/enforceActions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("enforcing actions", () => {
})

render(<Parent />)
expect(consoleWarnMock).not.toBeCalled()
expect(consoleWarnMock).not.toHaveBeenCalled()
})

it("'observed' should work", () => {
Expand All @@ -50,7 +50,7 @@ describe("enforcing actions", () => {
})

render(<Parent />)
expect(consoleWarnMock).toBeCalledTimes(1)
expect(consoleWarnMock).toHaveBeenCalledTimes(1)
})

it("'always' should work", () => {
Expand All @@ -69,6 +69,6 @@ describe("enforcing actions", () => {
})

render(<Parent />)
expect(consoleWarnMock).toBeCalledTimes(1)
expect(consoleWarnMock).toHaveBeenCalledTimes(1)
})
})
16 changes: 8 additions & 8 deletions packages/mobx-react-lite/__tests__/observer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -996,32 +996,32 @@ it("dependencies should not become temporarily unobserved", async () => {

expect(computed).toBe(1)
expect(renders).toBe(1)
expect(doubleDisposed).toBeCalledTimes(0)
expect(doubleDisposed).toHaveBeenCalledTimes(0)

store.inc()
expect(computed).toBe(2) // change propagated
expect(renders).toBe(1) // but not yet rendered
expect(doubleDisposed).toBeCalledTimes(0) // if we dispose to early, this fails!
expect(doubleDisposed).toHaveBeenCalledTimes(0) // if we dispose to early, this fails!

// Bug: change the state, before the useEffect fires, can cause the reaction to be disposed
mobx.reaction(() => store.x, reactionFired)
expect(reactionFired).toBeCalledTimes(0)
expect(reactionFired).toHaveBeenCalledTimes(0)
expect(computed).toBe(2) // Not 3!
expect(renders).toBe(1)
expect(doubleDisposed).toBeCalledTimes(0)
expect(doubleDisposed).toHaveBeenCalledTimes(0)

await runEffects()
expect(reactionFired).toBeCalledTimes(0)
expect(reactionFired).toHaveBeenCalledTimes(0)
expect(computed).toBe(2) // Not 3!
expect(renders).toBe(2)
expect(doubleDisposed).toBeCalledTimes(0)
expect(doubleDisposed).toHaveBeenCalledTimes(0)

r.unmount()
cleanups.filter(Boolean).forEach(f => f())
expect(reactionFired).toBeCalledTimes(0)
expect(reactionFired).toHaveBeenCalledTimes(0)
expect(computed).toBe(2)
expect(renders).toBe(2)
expect(doubleDisposed).toBeCalledTimes(1)
expect(doubleDisposed).toHaveBeenCalledTimes(1)
})

it.skip("Legacy context support", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
it("only when 'observed' should work", () => {
configure({ enforceActions: "observed" })
Expand All @@ -323,7 +323,7 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
it("'always' should work", () => {
configure({ enforceActions: "always" })
Expand All @@ -343,6 +343,6 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
it("only when 'observed' should work", () => {
configure({ enforceActions: "observed" })
Expand All @@ -386,7 +386,7 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
it("'always' should work", () => {
configure({ enforceActions: "always" })
Expand All @@ -406,7 +406,7 @@ describe("enforcing actions", () => {
}
}
)
expect(onError).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
})
})

Expand Down
12 changes: 6 additions & 6 deletions packages/mobx-react-lite/__tests__/useLocalObservable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ describe("enforcing actions", () => {
}
)

expect(onError).not.toBeCalled()
expect(consoleWarnMock).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
expect(consoleWarnMock).not.toHaveBeenCalled()
})
it("only when 'observed' should work", () => {
mobx.configure({ enforceActions: "observed" })
Expand Down Expand Up @@ -504,8 +504,8 @@ describe("enforcing actions", () => {
}
)

expect(onError).not.toBeCalled()
expect(consoleWarnMock).not.toBeCalled()
expect(onError).not.toHaveBeenCalled()
expect(consoleWarnMock).not.toHaveBeenCalled()
})
it("'always' should work", () => {
mobx.configure({ enforceActions: "always" })
Expand Down Expand Up @@ -540,7 +540,7 @@ describe("enforcing actions", () => {
}
)

expect(onError).not.toBeCalled()
expect(consoleWarnMock).toBeCalledTimes(2)
expect(onError).not.toHaveBeenCalled()
expect(consoleWarnMock).toHaveBeenCalledTimes(2)
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`computed properties react to props when using hooks 1`] = `
[MockFunction] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`#3492 should not cause warning by calling forceUpdate on uncommited components 1`] = `[MockFunction]`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`stateless component with forwardRef is reactive 1`] = `
<div>
Expand Down
2 changes: 1 addition & 1 deletion packages/mobx-react/__tests__/issue806.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test("verify issue 806", () => {
// make sure observableRequiresReaction is still working outside component
withConsole(["warn"], () => {
x.a.toString()
expect(console.warn).toBeCalledTimes(1)
expect(console.warn).toHaveBeenCalledTimes(1)
expect(console.warn).toHaveBeenCalledWith(
"[mobx] Observable 'ObservableObject@1.a' being read outside a reactive context."
)
Expand Down
6 changes: 3 additions & 3 deletions packages/mobx-react/__tests__/observer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ test("#3492 should not cause warning by calling forceUpdate on uncommited compon
}
)

expect(() => render(<TestCmp />)).toThrowError(
expect(() => render(<TestCmp />)).toThrow(
new RegExp(`^\\[mobx-react\\] Cannot read "TestCmp.${key}" in a reactive context`)
)

Expand Down Expand Up @@ -1108,8 +1108,8 @@ test(`Observable changes in componenWillUnmount don't cause any warnings or erro
expect(container).toHaveTextContent("0")
unmount()

expect(consoleErrorSpy).not.toBeCalled()
expect(consoleWarnSpy).not.toBeCalled()
expect(consoleErrorSpy).not.toHaveBeenCalled()
expect(consoleWarnSpy).not.toHaveBeenCalled()

consoleErrorSpy.mockRestore()
consoleWarnSpy.mockRestore()
Expand Down
4 changes: 2 additions & 2 deletions packages/mobx/__tests__/decorators_20223/stage3-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ test("ClassFieldDecorators should NOT work without accessor without legacy compi
class Order {
@observable price: number = 3
}
}).toThrowError("[MobX] Please use `@observable accessor price` instead of `@observable price`")
}).toThrow("[MobX] Please use `@observable accessor price` instead of `@observable price`")
})

test("Reasonable error for decorator kind mismatch", () => {
Expand All @@ -205,7 +205,7 @@ test("Reasonable error for decorator kind mismatch", () => {
// @ts-ignore
@computed total = 3
}
}).toThrowError("[MobX] The decorator applied to 'total' cannot be used on a field element")
}).toThrow("[MobX] The decorator applied to 'total' cannot be used on a field element")
})

test("typescript: parameterized computed decorator", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`very long arrays can be safely passed to nativeArray.concat #2379 1`] = `
[MockFunction] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`spy 1 1`] = `
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`computed value 1`] = `"ComputedValue@1[() => 3]"`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`observe & intercept 1`] = `
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`delay autorun until end of transaction 1`] = `
[
Expand Down
2 changes: 1 addition & 1 deletion packages/mobx/__tests__/v4/base/__snapshots__/spy.js.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing

exports[`spy error 1`] = `
[
Expand Down
2 changes: 1 addition & 1 deletion packages/mobx/__tests__/v4/base/autorun.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test("autorun can be disposed on first run", function () {
test("autorun warns when passed an action", function () {
const action = mobx.action(() => {})
expect.assertions(1)
expect(() => mobx.autorun(action)).toThrowError(/Autorun does not accept actions/)
expect(() => mobx.autorun(action)).toThrow(/Autorun does not accept actions/)
})

test("autorun batches automatically", function () {
Expand Down
Loading