diff --git a/packages/debugger/src/dependency/test/collect.test.ts b/packages/debugger/src/dependency/collect.test.ts
similarity index 96%
rename from packages/debugger/src/dependency/test/collect.test.ts
rename to packages/debugger/src/dependency/collect.test.ts
index 318aeb13..20cc22ff 100644
--- a/packages/debugger/src/dependency/test/collect.test.ts
+++ b/packages/debugger/src/dependency/collect.test.ts
@@ -1,18 +1,18 @@
-import '../../setup.ts'
+import '../setup.ts'
import * as s from 'solid-js'
import * as test from 'vitest'
-import {NodeType} from '../../main/constants.ts'
-import {ObjectType, getSdtId} from '../../main/id.ts'
-import setup from '../../main/setup.ts'
-import type {NodeID, Solid} from '../../main/types.ts'
-import {type SerializedDGraph, collectDependencyGraph} from '../collect.ts'
+import {NodeType} from '../main/constants.ts'
+import {ObjectType, getSdtId} from '../main/id.ts'
+import setup from '../main/setup.ts'
+import type {NodeID, Solid} from '../main/types.ts'
+import {type SerializedDGraph, collectDependencyGraph} from './collect.ts'
let mockLAST_ID = 0
test.beforeEach(() => {
mockLAST_ID = 0
})
-test.vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
+test.vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
test.describe('collectDependencyGraph', () => {
test.it('should collect dependency graph', () => {
diff --git a/packages/debugger/src/inspector/test/index.test.tsx b/packages/debugger/src/inspector/index.test.tsx
similarity index 71%
rename from packages/debugger/src/inspector/test/index.test.tsx
rename to packages/debugger/src/inspector/index.test.tsx
index a776ea72..3b73b53c 100644
--- a/packages/debugger/src/inspector/test/index.test.tsx
+++ b/packages/debugger/src/inspector/index.test.tsx
@@ -1,20 +1,14 @@
-import '../../setup.ts'
+import '../setup.ts'
import * as s from 'solid-js'
-import {beforeEach, describe, expect, it, vi} from 'vitest'
-import {getObjectById, getSdtId, ObjectType} from '../../main/id.ts'
-import setup from '../../main/setup.ts'
-import {type Mapped, NodeType, PropGetterState, type Solid, ValueType} from '../../types.ts'
-import {collectOwnerDetails} from '../inspector.ts'
-
-let mockLAST_ID = 0
-beforeEach(() => {
- mockLAST_ID = 0
-})
-vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
-
-describe('collectOwnerDetails', () => {
- it('collects focused owner details', () => {
+import * as test from 'vitest'
+import {getObjectById, getSdtId, ObjectType} from '../main/id.ts'
+import setup from '../main/setup.ts'
+import {type Mapped, NodeType, PropGetterState, type Solid, ValueType} from '../types.ts'
+import {collectOwnerDetails} from './inspector.ts'
+
+test.describe('collectOwnerDetails', () => {
+ test.it('collects focused owner details', () => {
s.createRoot(dispose => {
const [source] = s.createSignal(0, {name: 'source'})
@@ -57,7 +51,7 @@ describe('collectOwnerDetails', () => {
},
})
- expect(details).toEqual({
+ test.expect(details).toEqual({
id: getSdtId(memo, ObjectType.Owner),
name: 'focused',
type: NodeType.Memo,
@@ -84,26 +78,29 @@ describe('collectOwnerDetails', () => {
],
} satisfies Mapped.OwnerDetails)
- expect(valueMap.get(`signal:${getSdtId(customValue, ObjectType.CustomValue)}`)).toBeTruthy()
- expect(valueMap.get(`signal:${getSdtId(signalB, ObjectType.Signal)}`)).toBeTruthy()
- expect(valueMap.get(`signal:${getSdtId(innerMemo, ObjectType.Owner)}`)).toBeTruthy()
+ test.expect(valueMap.get(`signal:${getSdtId(customValue, ObjectType.CustomValue)}`)).toBeTruthy()
+ test.expect(valueMap.get(`signal:${getSdtId(signalB, ObjectType.Signal)}`)).toBeTruthy()
+ test.expect(valueMap.get(`signal:${getSdtId(innerMemo, ObjectType.Owner)}`)).toBeTruthy()
- expect(getObjectById('#3', ObjectType.Element)).toBe(div)
+ test.expect(getObjectById('#3', ObjectType.Element)).toBe(div)
dispose()
})
})
- it('component props', () => {
+ test.it('component props', () => {
s.createRoot(dispose => {
+
let owner!: Solid.Owner
+ let div_ref!: HTMLDivElement
+
const TestComponent = (props: {
count: number
children: s.JSX.Element
nested: {foo: number; bar: string}
}) => {
owner = setup.solid.getOwner()!
- return
{props.children}
+ return {props.children}
}
s.createRenderEffect(() => (
@@ -123,12 +120,12 @@ describe('collectOwnerDetails', () => {
dispose()
- expect(details).toEqual({
- id: '#0',
+ test.expect(details).toEqual({
+ id: getSdtId(owner, ObjectType.Owner),
name: 'TestComponent',
type: NodeType.Component,
signals: [],
- value: [[ValueType.Element, '#1:div']],
+ value: [[ValueType.Element, `${getSdtId(div_ref, ObjectType.Element)}:div`]],
props: {
proxy: false,
record: {
@@ -147,14 +144,15 @@ describe('collectOwnerDetails', () => {
},
},
} satisfies Mapped.OwnerDetails)
-
- expect(getObjectById('#1', ObjectType.Element)).toBeInstanceOf(HTMLDivElement)
})
})
- it('dynamic component props', () => {
+ test.it('dynamic component props', () => {
s.createRoot(dispose => {
+
let owner!: Solid.Owner
+ let el_ref!: HTMLDivElement
+
const Button = (props: s.JSX.ButtonHTMLAttributes) => {
owner = setup.solid.getOwner()!
return
@@ -167,7 +165,7 @@ describe('collectOwnerDetails', () => {
},
role: 'button',
}) as const
- return
+ return (el_ref = as any)
})
const {details} = collectOwnerDetails(owner, {
@@ -180,12 +178,12 @@ describe('collectOwnerDetails', () => {
},
})
- expect(details).toEqual({
- id: '#0',
+ test.expect(details).toEqual({
+ id: getSdtId(owner, ObjectType.Owner),
name: 'Button',
type: NodeType.Component,
signals: [],
- value: [[ValueType.Element, '#1:button']],
+ value: [[ValueType.Element, `${getSdtId(el_ref, ObjectType.Element)}:button`]],
props: {
proxy: true,
record: {
@@ -201,13 +199,11 @@ describe('collectOwnerDetails', () => {
},
} satisfies Mapped.OwnerDetails)
- expect(getObjectById('#1', ObjectType.Element)).toBeInstanceOf(HTMLButtonElement)
-
dispose()
})
})
- it('listens to value updates', () => {
+ test.it('listens to value updates', () => {
s.createRoot(dispose => {
let owner!: Solid.Owner
@@ -217,7 +213,7 @@ describe('collectOwnerDetails', () => {
return count()
})
- const onValueUpdate = vi.fn()
+ const onValueUpdate = test.vi.fn()
collectOwnerDetails(owner, {
observedPropsMap: new WeakMap(),
onPropStateChange: () => {
@@ -226,30 +222,32 @@ describe('collectOwnerDetails', () => {
onValueUpdate: onValueUpdate,
})
- expect(onValueUpdate).not.toBeCalled()
+ test.expect(onValueUpdate).not.toBeCalled()
setCount(1)
- expect(onValueUpdate).toBeCalledTimes(1)
- expect(onValueUpdate).toHaveBeenLastCalledWith('value')
+ test.expect(onValueUpdate).toBeCalledTimes(1)
+ test.expect(onValueUpdate).toHaveBeenLastCalledWith('value')
setCount(2)
- expect(onValueUpdate).toBeCalledTimes(2)
- expect(onValueUpdate).toHaveBeenLastCalledWith('value')
+ test.expect(onValueUpdate).toBeCalledTimes(2)
+ test.expect(onValueUpdate).toHaveBeenLastCalledWith('value')
setCount(2)
- expect(onValueUpdate).toBeCalledTimes(2)
+ test.expect(onValueUpdate).toBeCalledTimes(2)
dispose()
})
})
- it('listens to signal updates', () => {
+ test.it('listens to signal updates', () => {
s.createRoot(dispose => {
const owner = setup.solid.getOwner()!
- const [, setCount] = s.createSignal(0) // id: "0"
- const [, setCount2] = s.createSignal(0) // id: "1"
+ const [, setCount1] = s.createSignal(0)
+ const [, setCount2] = s.createSignal(0)
+
+ const [count1, count2] = owner.sourceMap as [Solid.Signal, Solid.Signal]
- const onValueUpdate = vi.fn()
+ const onValueUpdate = test.vi.fn()
collectOwnerDetails(owner, {
observedPropsMap: new WeakMap(),
onPropStateChange: () => {
@@ -258,18 +256,18 @@ describe('collectOwnerDetails', () => {
onValueUpdate: onValueUpdate,
})
- expect(onValueUpdate).not.toBeCalled()
+ test.expect(onValueUpdate).not.toBeCalled()
- setCount(1)
- expect(onValueUpdate).toBeCalledTimes(1)
- expect(onValueUpdate).toHaveBeenLastCalledWith('signal:#1')
+ setCount1(1)
+ test.expect(onValueUpdate).toBeCalledTimes(1)
+ test.expect(onValueUpdate).toHaveBeenLastCalledWith(`signal:${getSdtId(count1, ObjectType.Signal)}`)
- setCount(1)
- expect(onValueUpdate).toBeCalledTimes(1)
+ setCount1(1)
+ test.expect(onValueUpdate).toBeCalledTimes(1)
setCount2(1)
- expect(onValueUpdate).toBeCalledTimes(2)
- expect(onValueUpdate).toHaveBeenLastCalledWith('signal:#2')
+ test.expect(onValueUpdate).toBeCalledTimes(2)
+ test.expect(onValueUpdate).toHaveBeenLastCalledWith(`signal:${getSdtId(count2, ObjectType.Signal)}`)
dispose()
})
diff --git a/packages/debugger/src/inspector/test/serialize.test.ts b/packages/debugger/src/inspector/serialize.test.ts
similarity index 97%
rename from packages/debugger/src/inspector/test/serialize.test.ts
rename to packages/debugger/src/inspector/serialize.test.ts
index 0854b2a6..9180fb9e 100644
--- a/packages/debugger/src/inspector/test/serialize.test.ts
+++ b/packages/debugger/src/inspector/serialize.test.ts
@@ -1,14 +1,14 @@
-import '../../setup.ts'
+import '../setup.ts'
import {type Truthy} from '@solid-primitives/utils'
import {createMutable, createStore} from 'solid-js/store'
import {describe, expect, test, vi} from 'vitest'
-import {ObjectType, getObjectById} from '../../main/id.ts'
-import {encodeValue} from '../serialize.ts'
-import {type EncodedValue, INFINITY, NAN, NEGATIVE_INFINITY, UNDEFINED, ValueType} from '../types.ts'
+import {ObjectType, getObjectById} from '../main/id.ts'
+import {encodeValue} from './serialize.ts'
+import {type EncodedValue, INFINITY, NAN, NEGATIVE_INFINITY, UNDEFINED, ValueType} from './types.ts'
let mockLAST_ID = 0
-vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
+vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
type Expectations = [name: string, data: unknown, encoded: EncodedValue[]][]
diff --git a/packages/debugger/src/inspector/test/store.test.ts b/packages/debugger/src/inspector/store.test.ts
similarity index 96%
rename from packages/debugger/src/inspector/test/store.test.ts
rename to packages/debugger/src/inspector/store.test.ts
index 31337c1f..e8bd8656 100644
--- a/packages/debugger/src/inspector/test/store.test.ts
+++ b/packages/debugger/src/inspector/store.test.ts
@@ -1,13 +1,13 @@
-import '../../setup.ts'
+import '../setup.ts'
import {createRoot} from 'solid-js'
import {createMutable, createStore, modifyMutable, produce, reconcile, unwrap} from 'solid-js/store'
import {beforeEach, describe, expect, it, vi} from 'vitest'
-import {ObjectType, getSdtId} from '../../main/id.ts'
-import setup from '../../main/setup.ts'
-import {isSolidStore} from '../../main/utils.ts'
-import {type Solid} from '../../types.ts'
-import {type OnNodeUpdate, type StoreNodeProperty, observeStoreNode, setOnStoreNodeUpdate} from '../store.ts'
+import {ObjectType, getSdtId} from '../main/id.ts'
+import setup from '../main/setup.ts'
+import {isSolidStore} from '../main/utils.ts'
+import {type Solid} from '../types.ts'
+import {type OnNodeUpdate, type StoreNodeProperty, observeStoreNode, setOnStoreNodeUpdate} from './store.ts'
const getOwnerStore = () => {
const owner = setup.solid.getOwner()
@@ -25,7 +25,7 @@ let mockLAST_ID = 0
beforeEach(() => {
mockLAST_ID = 0
})
-vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
+vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
type UpdateParams = Parameters
diff --git a/packages/debugger/src/locator/test/index.test.ts b/packages/debugger/src/locator/index.test.ts
similarity index 91%
rename from packages/debugger/src/locator/test/index.test.ts
rename to packages/debugger/src/locator/index.test.ts
index 7befa378..cc0d2f28 100644
--- a/packages/debugger/src/locator/test/index.test.ts
+++ b/packages/debugger/src/locator/index.test.ts
@@ -8,7 +8,7 @@ vi.mock('@solid-primitives/platform', () => ({
},
}))
-const fetchFunction = async () => (await import('../find-components.ts')).parseLocationString
+const fetchFunction = async () => (await import('./find-components.ts')).parseLocationString
describe('locator attribute pasting', () => {
beforeEach(() => {
diff --git a/packages/debugger/src/main/test/update.test.ts b/packages/debugger/src/main/update.test.ts
similarity index 97%
rename from packages/debugger/src/main/test/update.test.ts
rename to packages/debugger/src/main/update.test.ts
index a9e4ba47..9d7a85f0 100644
--- a/packages/debugger/src/main/test/update.test.ts
+++ b/packages/debugger/src/main/update.test.ts
@@ -1,4 +1,4 @@
-import '../../setup.ts'
+import '../setup.ts'
import {createComputed, createRoot, createSignal, onCleanup} from 'solid-js'
import {describe, expect, it} from 'vitest'
@@ -7,8 +7,8 @@ import {
interceptComputationRerun,
observeValueUpdate,
removeValueUpdateObserver,
-} from '../observe.ts'
-import setup from '../setup.ts'
+} from './observe.ts'
+import setup from './setup.ts'
describe('addSolidUpdateListener', () => {
it('listens to solid updates', () =>
diff --git a/packages/debugger/src/main/test/utils.test.ts b/packages/debugger/src/main/utils.test.ts
similarity index 96%
rename from packages/debugger/src/main/test/utils.test.ts
rename to packages/debugger/src/main/utils.test.ts
index f1272f73..1ef0b209 100644
--- a/packages/debugger/src/main/test/utils.test.ts
+++ b/packages/debugger/src/main/utils.test.ts
@@ -1,11 +1,11 @@
-import '../../setup.ts'
+import '../setup.ts'
import * as s from 'solid-js'
import * as vi from 'vitest'
-import {NodeType} from '../constants.ts'
+import {NodeType} from './constants.ts'
import {type Solid} from '../types.ts'
-import * as utils from '../utils.ts'
-import setup from '../setup.ts'
+import * as utils from './utils.ts'
+import setup from './setup.ts'
vi.describe('getOwnerType', () => {
const tests = {
diff --git a/packages/debugger/src/structure/test/walker.test.tsx b/packages/debugger/src/structure/walker.test.tsx
similarity index 97%
rename from packages/debugger/src/structure/test/walker.test.tsx
rename to packages/debugger/src/structure/walker.test.tsx
index 3282ac45..c0f2a463 100644
--- a/packages/debugger/src/structure/test/walker.test.tsx
+++ b/packages/debugger/src/structure/walker.test.tsx
@@ -1,14 +1,14 @@
-import '../../setup.ts'
+import '../setup.ts'
import * as s from 'solid-js'
import * as test from 'vitest'
-import {NodeType, TreeWalkerMode} from '../../main/constants.ts'
-import {$setSdtId} from '../../main/id.ts'
-import {type Mapped, type Solid} from '../../main/types.ts'
-import {getNodeName} from '../../main/utils.ts'
-import {type ComputationUpdateHandler, walkSolidTree} from '../walker.ts'
-import setup from '../../main/setup.ts'
-import {initRoots} from '../../main/roots.ts'
+import {NodeType, TreeWalkerMode} from '../main/constants.ts'
+import {$setSdtId} from '../main/id.ts'
+import {type Mapped, type Solid} from '../main/types.ts'
+import {getNodeName} from '../main/utils.ts'
+import {type ComputationUpdateHandler, walkSolidTree} from './walker.ts'
+import setup from '../main/setup.ts'
+import {initRoots} from '../main/roots.ts'
test.beforeAll(() => {
initRoots()
@@ -18,7 +18,7 @@ let mockLAST_ID = 0
test.beforeEach(() => {
mockLAST_ID = 0
})
-test.vi.mock('../../main/get-id', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
+test.vi.mock('../main/get-id.ts', () => ({getNewSdtId: () => '#' + mockLAST_ID++}))
test.describe('TreeWalkerMode.Owners', () => {
test.it('default options', () => {
diff --git a/packages/debugger/test_setup.ts b/packages/debugger/test_setup.ts
deleted file mode 100644
index 3ec600e6..00000000
--- a/packages/debugger/test_setup.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-// /* Run setup before importing the debugger */
-// import * as solid from 'solid-js'
-// import * as store from 'solid-js/store'
-// import {setupSolidDevtools} from './src/setup.ts'
-// setupSolidDevtools(solid.DEV, store.DEV)
-
-// import {startObserve} from './src/main/observe.ts'
-// startObserve()
-
-// import {startObservingStores} from './src/inspector/store.ts'
-// startObservingStores()