-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(betterer ✨): borrow merge conflict handler from yarn (#141)
- Loading branch information
1 parent
a726472
commit 5c396eb
Showing
5 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`betterer should work when there is a merge conflict in the results file 1`] = ` | ||
Array [ | ||
" | ||
/ | / _ _ _ | ||
'-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __ | ||
---ooooo--- | '_ / / _ / __| __/ _ / '__/ _ / '__| | ||
.-'ooo'-. | |_) | __/ |_| || __/ | | __/ | | ||
/ | / |_.__/ /___|/__|/__/___|_| /___|_| | ||
", | ||
" ☀️ betterer info 💬 - ", | ||
"running \\"no raw console calls\\"!", | ||
" ☀️ betterer warn 🚨 - ", | ||
"\\"no raw console calls\\" stayed the same. 😐", | ||
" ☀️ betterer info 💬 - ", | ||
"1 test got checked. 🤔", | ||
" ☀️ betterer warn 🚨 - ", | ||
"1 test stayed the same. 😐", | ||
] | ||
`; | ||
|
||
exports[`betterer should work when there is a merge conflict in the results file 2`] = ` | ||
"// BETTERER RESULTS V1. | ||
exports[\`no raw console calls\`] = { | ||
timestamp: 0, | ||
value: \`{ | ||
\\"src/index.ts:1884655653\\": [ | ||
[0, 0, 11, \\"TSQuery match\\", \\"3870399096\\"] | ||
] | ||
}\` | ||
}; | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { betterer } from '@betterer/betterer'; | ||
|
||
import { createFixture } from './fixture'; | ||
|
||
describe('betterer', () => { | ||
it('should work when there is a merge conflict in the results file', async () => { | ||
const { logs, paths, readFile, cleanup } = await createFixture('test-betterer-conflict', { | ||
'.betterer.ts': ` | ||
import { tsquery } from '@betterer/tsquery'; | ||
export default { | ||
'no raw console calls': tsquery( | ||
'./tsconfig.json', | ||
'CallExpression > PropertyAccessExpression[expression.name="console"][name.name="log"]' | ||
) | ||
}; | ||
`, | ||
'.betterer.results': ` | ||
// BETTERER RESULTS V1. | ||
exports[\`no raw console calls\`] = { | ||
timestamp: 0, | ||
value: \`{ | ||
|||<<<<<<< our-change | ||
\\"src/index.ts:315583663\\": [ | ||
[0, 0, 11, \\"TSQuery match\\", \\"3870399096\\"], | ||
[1, 0, 11, \\"TSQuery match\\", \\"3870399096\\"] | ||
] | ||
|||======= | ||
\\"src/index.ts:913095150\\": [ | ||
[0, 0, 11, \\"TSQuery match\\", \\"3870399096\\"] | ||
] | ||
|||>>>>>>> their-change | ||
}\` | ||
}; | ||
`.replace(/\|||/g, ''), // Mess with it a bit so that tooling doesn't think this is a real conflict: | ||
'tsconfig.json': ` | ||
{ | ||
"compilerOptions": { | ||
"noEmit": true, | ||
"lib": ["esnext"], | ||
"moduleResolution": "node", | ||
"target": "ES5", | ||
"typeRoots": ["../../node_modules/@types/"], | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["./src/**/*", ".betterer.ts"] | ||
} | ||
`, | ||
'src/index.ts': ` | ||
console.log('foo'); | ||
console.info('foo'); | ||
` | ||
}); | ||
|
||
const configPaths = [paths.config]; | ||
const resultsPath = paths.results; | ||
|
||
await betterer({ configPaths, resultsPath }); | ||
|
||
expect(logs).toMatchSnapshot(); | ||
|
||
const result = await readFile(resultsPath); | ||
|
||
expect(result).toMatchSnapshot(); | ||
|
||
await cleanup(); | ||
}); | ||
}); |