Skip to content

Commit

Permalink
test: stable deep sort array
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Feb 6, 2022
1 parent 7aa5674 commit 437a607
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"prompts": "^2.4.1",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"sort-deep-object-arrays": "^1.1.2",
"strip-ansi": "^7.0.0",
"svelte": "^3.46.3",
"ts-jest": "^27.1.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`multiple-hmr serve get initial error and subsequent error 1`] = `"[{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(1)/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":3,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Unexpected var, use let or const instead.\\",\\"plugin\\":\\"ESLint\\",\\"stack\\":\\"\\"},{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(1)/n | ^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":44,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Argument of type 'number' is not assignable to parameter of type 'string | (() => string)'.\\",\\"plugin\\":\\"TypeScript\\",\\"stack\\":\\"\\"}]"`;
exports[`multiple-hmr serve get initial error and subsequent error 1`] = `"[{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(1)/n | ^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":44,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Argument of type 'number' is not assignable to parameter of type 'string | (() => string)'.\\",\\"plugin\\":\\"TypeScript\\",\\"stack\\":\\"\\"},{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(1)/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":3,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Unexpected var, use let or const instead.\\",\\"plugin\\":\\"ESLint\\",\\"stack\\":\\"\\"}]"`;

exports[`multiple-hmr serve get initial error and subsequent error 2`] = `
" ERROR(ESLint) Unexpected var, use let or const instead.
Expand Down Expand Up @@ -28,7 +28,7 @@ exports[`multiple-hmr serve get initial error and subsequent error 2`] = `
Found 1 error. Watching for file changes."
`;
exports[`multiple-hmr serve get initial error and subsequent error 3`] = `"[{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(2)/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":3,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Unexpected var, use let or const instead.\\",\\"plugin\\":\\"ESLint\\",\\"stack\\":\\"\\"},{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(2)/n | ^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":44,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Argument of type 'number' is not assignable to parameter of type 'string | (() => string)'.\\",\\"plugin\\":\\"TypeScript\\",\\"stack\\":\\"\\"}]"`;
exports[`multiple-hmr serve get initial error and subsequent error 3`] = `"[{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(2)/n | ^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":44,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Argument of type 'number' is not assignable to parameter of type 'string | (() => string)'.\\",\\"plugin\\":\\"TypeScript\\",\\"stack\\":\\"\\"},{\\"frame\\":\\" 4 |/n 5 | function App() {/n > 6 | var [count, setCount] = useState<string>(2)/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 7 | return (/n 8 | <div className=/\\"App/\\">/n 9 | <header className=/\\"App-header/\\">\\",\\"id\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"loc\\":{\\"column\\":3,\\"file\\":\\"<PROJECT_ROOT>/temp/multiple-hmr/src/App.tsx\\",\\"line\\":6},\\"message\\":\\"Unexpected var, use let or const instead.\\",\\"plugin\\":\\"ESLint\\",\\"stack\\":\\"\\"}]"`;
exports[`multiple-hmr serve get initial error and subsequent error 4`] = `
" ERROR(ESLint) Unexpected var, use let or const instead.
Expand Down
10 changes: 6 additions & 4 deletions playground/multiple-hmr/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import stringify from 'fast-json-stable-stringify'
// @ts-expect-error
import stable from 'sort-deep-object-arrays'
import {
killServer,
preTest,
Expand Down Expand Up @@ -52,15 +54,15 @@ describe('multiple-hmr', () => {
proxyConsole: () => proxyConsoleInTest(true),
})
await sleepForServerReady()
expect(stringify(errors.sort())).toMatchSnapshot()
expect(stringify(stable(errors))).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()

console.log('-- edit with error --')
errors = []
resetReceivedLog()
editFile('src/App.tsx', (code) => code.replace('useState<string>(1)', 'useState<string>(2)'))
await sleepForEdit()
expect(stringify(errors.sort())).toMatchSnapshot()
expect(stringify(stable(errors))).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()

console.log('-- fix typescript error --')
Expand All @@ -70,15 +72,15 @@ describe('multiple-hmr', () => {
code.replace('useState<string>(2)', `useState<string>('x')`)
)
await sleepForEdit()
expect(stringify(errors.sort())).toMatchSnapshot()
expect(stringify(stable(errors))).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()

console.log('-- fix eslint error --')
errors = []
resetReceivedLog()
editFile('src/App.tsx', (code) => code.replace('var', 'const'))
await sleepForEdit()
expect(stringify(errors.sort())).toMatchSnapshot()
expect(stringify(stable(errors))).toMatchSnapshot()
expect(stripedLog).toMatchSnapshot()
})
})
Expand Down
Loading

0 comments on commit 437a607

Please sign in to comment.