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
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: release
on:
push: {}
push:
branches:
- 'master'
pull_request: {}
jobs:
main:
Expand All @@ -15,9 +17,11 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '15.11.0'
- name: Install deps
# this runs a build script so there is no dedicated build
run: yarn install
run: |
npm i -g yarn
yarn install
- name: Run tests
run: yarn test:ts && yarn test
23 changes: 15 additions & 8 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,32 @@ function createConfig(rootDir) {
const { compilerOptions } = fs.readJsonSync(
path.join(rootDir, 'tsconfig.json')
)

return {
rootDir,
setupFilesAfterEnv:
rootDir.indexOf('shared') < 0
? [path.join(__dirname, 'packages/core/test/setup.ts')]
: [],
preset: 'ts-jest',
setupFilesAfterEnv: [path.join(__dirname, 'packages/core/test/setup.ts')],
testMatch,
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['.+/(types|__snapshots__)/.+'],
testPathIgnorePatterns: [
'.+/(types|__snapshots__)/.+',
'<rootDir>/node_modules/',
],
modulePathIgnorePatterns: ['dist'],
moduleNameMapper: {
'^react$': '<rootDir>/../../node_modules/react',
},
transform: {
'^.+\\.tsx?$': 'esbuild-jest',
},
collectCoverageFrom: ['src/**/*'],
coverageDirectory: './coverage',
moduleFileExtensions: ['js', 'ts', 'tsx'],
coverageReporters: ['json', 'html', 'text'],
timers: 'fake',
globals: {
'ts-jest': {
tsconfig: {
...compilerOptions,
},
},
},
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,19 @@
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/jest": "^24.0.13",
"@types/jest": "^26.0.21",
"@types/node": "^14.14.35",
"@types/react": "^16.8.19",
"build-if-changed": "^1.5.0",
"chalk": "^2.4.2",
"copyfiles": "^2.4.1",
"enquirer": "^2.3.2",
"esbuild": "^0.8.0",
"esbuild-jest": "^0.2.2",
"execa": "^2.0.4",
"flush-microtasks": "^1.0.1",
"fs-extra": "7.0.1",
"husky": "1.3.1",
"jest": "^25.1.0",
"jest": "^26.6.3",
"jest-watch-typeahead": "^0.3.1",
"lerna": "3.15.0",
"meta": "^1.2.19",
Expand All @@ -89,7 +88,8 @@
"sade": "^1.6.1",
"sort-package-json": "1.22.1",
"spec.ts": "1.1.3",
"typescript": "^4.0.0",
"ts-jest": "^26.5.4",
"typescript": "^4.2.3",
"typescript-rewrite-paths": "^1.2.0"
},
"publishConfig": {
Expand Down
1 change: 1 addition & 0 deletions packages/animated/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"preserveSymlinks": true,
"sourceMap": true,
"strict": true,
"esModuleInterop": true,
"target": "esnext",
"typeRoots": ["../../node_modules/@types"]
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"directory": "dist"
},
"devDependencies": {
"@testing-library/react": "^9.4.0",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"rafz": "link:../shared/node_modules/rafz",
"react-dom": "^16.12.0"
}
Expand Down
66 changes: 33 additions & 33 deletions packages/core/src/Controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ describe('Controller', () => {
const ctrl = new Controller({ x: 0 })
ctrl.start({ x: 100 })

await advanceUntilIdle()
const frames = getFrames(ctrl)
await global.advanceUntilIdle()
const frames = global.getFrames(ctrl)
expect(frames).toMatchSnapshot()

// The first frame should *not* be the from value.
Expand All @@ -24,8 +24,8 @@ describe('Controller', () => {
const ctrl = new Controller<{ x: [number, number] }>({ x: [1, 2], config })
ctrl.start({ x: [5, 10] })

await advanceUntilIdle()
const frames = getFrames(ctrl)
await global.advanceUntilIdle()
const frames = global.getFrames(ctrl)
expect(frames).toMatchSnapshot()

// The last frame should be the goal value.
Expand All @@ -50,7 +50,7 @@ describe('Controller', () => {
})

const { x } = ctrl.springs
await advanceUntilValue(x, 0.5)
await global.advanceUntilValue(x, 0.5)

ctrl.start({ cancel: true })
await flushMicroTasks()
Expand All @@ -70,7 +70,7 @@ describe('Controller', () => {
})

const { x } = ctrl.springs
await advanceUntilValue(x, 0.5)
await global.advanceUntilValue(x, 0.5)

ctrl.stop()

Expand Down Expand Up @@ -114,14 +114,14 @@ describe('Controller', () => {
},
})

await advance()
await global.advance()
expect(n).toBe(1)

ctrl.start({
to: () => {},
})

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(n).toBe(1)

expect(await promise).toMatchObject({
Expand All @@ -144,7 +144,7 @@ describe('Controller', () => {
await animate({ x: 0 })
},
})
await advanceUntilIdle()
await global.advanceUntilIdle()
expect(onStart).toBeCalledTimes(2)
})

Expand All @@ -168,7 +168,7 @@ describe('Controller', () => {
},
})

await advanceUntilIdle()
await global.advanceUntilIdle()
await flushMicroTasks()

expect(nestedFn).toBeCalledTimes(1)
Expand All @@ -193,7 +193,7 @@ describe('Controller', () => {
},
})

await advanceUntilValue(x, 0.5)
await global.advanceUntilValue(x, 0.5)
ctrl.start({ cancel: true })
await flushMicroTasks()

Expand All @@ -213,11 +213,11 @@ describe('Controller', () => {
onRest,
})

mockRaf.step()
global.mockRaf.step()
ctrl.pause()

t.finish()
mockRaf.step()
global.mockRaf.step()

expect(ctrl['_state'].paused).toBeTruthy()
expect(onRest).not.toBeCalled()
Expand Down Expand Up @@ -249,11 +249,11 @@ describe('Controller', () => {
},
})

await Promise.all([advanceUntilIdle(), promise])
await Promise.all([global.advanceUntilIdle(), promise])
expect(ctrl.idle).toBeTruthy()

// Since we call `update` twice, frames are generated!
expect(getFrames(ctrl)).toMatchSnapshot()
expect(global.getFrames(ctrl)).toMatchSnapshot()
})
})

Expand All @@ -268,7 +268,7 @@ describe('Controller', () => {
onStart,
})

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(onStart).toBeCalledTimes(1)
})

Expand All @@ -281,7 +281,7 @@ describe('Controller', () => {
const onStart2 = jest.fn()
ctrl.start({ y: 1, onStart: onStart2 })

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(onStart1).toBeCalledTimes(1)
expect(onStart2).toBeCalledTimes(1)
})
Expand All @@ -298,16 +298,16 @@ describe('Controller', () => {
const { t } = ctrl.springs
expect(t.get()).toBe(0)

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(t.get()).toBe(1)

ctrl.start({
loop: { reverse: true },
})

await advanceUntilValue(t, 0)
await advanceUntilValue(t, 1)
expect(getFrames(t)).toMatchSnapshot()
await global.advanceUntilValue(t, 0)
await global.advanceUntilValue(t, 1)
expect(global.getFrames(t)).toMatchSnapshot()
})

describe('used with multiple values', () => {
Expand All @@ -323,7 +323,7 @@ describe('Controller', () => {

const { x, y } = ctrl.springs
for (let i = 0; i < 2; i++) {
await advanceUntilValue(y, 1)
await global.advanceUntilValue(y, 1)

// Both values should equal their "from" value at the same time.
expect(x.get()).toBe(x.animation.from)
Expand Down Expand Up @@ -355,18 +355,18 @@ describe('Controller', () => {
},
})

await advanceUntilValue(t, 1)
await global.advanceUntilValue(t, 1)
expect(t.idle).toBeFalsy()

for (let i = 0; i < 2; i++) {
await advanceUntilValue(t, 0)
await global.advanceUntilValue(t, 0)
expect(t.idle).toBeFalsy()

await advanceUntilValue(t, 1)
await global.advanceUntilValue(t, 1)
expect(t.idle).toBeFalsy()
}

await advanceUntilValue(t, 0)
await global.advanceUntilValue(t, 0)
expect(t.idle).toBeTruthy()
})
})
Expand All @@ -387,16 +387,16 @@ describe('Controller', () => {
})

for (let i = 0; i < 3; i++) {
await advanceUntilValue(t, 2)
await global.advanceUntilValue(t, 2)
expect(t.idle).toBeFalsy()

// Run the first frame of the next loop.
mockRaf.step()
global.mockRaf.step()
}

loop = false

await advanceUntilValue(t, 2)
await global.advanceUntilValue(t, 2)
expect(t.idle).toBeTruthy()

expect(await promise).toMatchObject({
Expand All @@ -414,7 +414,7 @@ describe('Controller', () => {
const loop = jest.fn(() => true)
ctrl.start({ t: 0, loop })

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(loop).toBeCalledTimes(0)
})
})
Expand All @@ -437,7 +437,7 @@ describe('Controller', () => {
await flushMicroTasks()

// Apply the first frame.
mockRaf.step()
global.mockRaf.step()

ctrl.pause()
return ctrl
Expand Down Expand Up @@ -490,7 +490,7 @@ describe('Controller', () => {
ctrl.start({ t: 1, delay: 100 })
ctrl.stop()

await advanceUntilIdle()
await global.advanceUntilIdle()
expect(ctrl['_state'].timeouts.size).toBe(0)
expect(t['_state'].timeouts.size).toBe(0)
})
Expand All @@ -503,7 +503,7 @@ describe('Controller', () => {
},
})
ctrl.stop()
await advanceUntilIdle()
await global.advanceUntilIdle()
expect(ctrl['_state'].asyncTo).toBeUndefined()
})
})
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Interpolation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Interpolation', () => {
it('leaves the frameloop', () => {
const a = new SpringValue({ from: 0, to: 1 })
const b = new SpringValue({ from: 1, to: 0 })
mockRaf.step()
global.mockRaf.step()

const calc = jest.fn((a: number, b: number) => Math.abs(a - b))
const c = to([a, b], calc)
Expand All @@ -33,7 +33,7 @@ describe('Interpolation', () => {

// Expect interpolation to continue.
calc.mockClear()
mockRaf.step()
global.mockRaf.step()
expect(calc).toBeCalled()

// Pause the other input.
Expand All @@ -43,13 +43,13 @@ describe('Interpolation', () => {
// When its value stays the same, it checks the idle status of each input,
// which triggers an update to its own idle status.
calc.mockClear()
mockRaf.step()
global.mockRaf.step()
expect(calc).toBeCalled()
expect(c.idle).toBeTruthy()

// Expect interpolation to be paused.
calc.mockClear()
mockRaf.step()
global.mockRaf.step()
expect(calc).not.toBeCalled()
})
})
Expand Down
Loading