-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the first integration test #124
Open
illright
wants to merge
16
commits into
master
Choose a base branch
from
e2e
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+363
−16
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d53dcf0
Add a rudimentary E2E test
illright 454e367
Revert "Fix compilerOptions.paths resolution on Windows (#123)"
illright b2b084b
.
illright 524d860
.
illright bf85a0b
oops
illright eeed792
fix paths
illright 0a7f7a4
.
illright c2baf79
Merge branch 'master' into e2e
illright fa9b32c
Remove crap [skip ci]
illright f3f6865
Rebuild the integration test into a separate package
illright 6393104
Make it NO_COLOR
illright 75a0ea5
remove the crap
illright 1e1b499
Update Windows snapshots to use fallback figures
illright d618d82
Try fixing the bundle size workflow also
illright e108162
Clean up
illright 1faf5c5
Add a changeset
illright File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'steiger': patch | ||
--- | ||
|
||
The diagnostics from a single rule are now sorted by path in alphabetical order |
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 @@ | ||
export const App = {} |
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 @@ | ||
export { App } from './App' |
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,3 @@ | ||
import { App } from '@/app/ui/App' | ||
|
||
console.log(App) |
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,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"jsx": "react-jsx", | ||
"moduleResolution": "Bundler", | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["src/*"] | ||
} | ||
}, | ||
"include": ["src"] | ||
} |
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
{} | ||
{ | ||
"files": [], | ||
"references": [{ "path": "./tsconfig.app.json" }] | ||
} |
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 @@ | ||
export { default } from '@steiger/eslint-config' |
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,37 @@ | ||
{ | ||
"private": true, | ||
"name": "@steiger/integration-tests", | ||
"description": "Integration tests for Steiger", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"test": "vitest run", | ||
"update-windows-snapshots": "node ./scripts/update-windows-snapshots.mjs" | ||
}, | ||
"exports": { | ||
".": "./src/index.ts" | ||
}, | ||
"type": "module", | ||
"authors": [ | ||
{ | ||
"name": "Lev Chelyadinov", | ||
"email": "[email protected]", | ||
"url": "https://github.com/illright" | ||
} | ||
], | ||
"devDependencies": { | ||
"@steiger/eslint-config": "workspace:*", | ||
"@steiger/tsconfig": "workspace:*", | ||
"@total-typescript/ts-reset": "^0.6.1", | ||
"@types/node": "^18.11.9", | ||
"eslint": "^9.16.0", | ||
"figures": "^6.1.0", | ||
"get-bin-path": "^11.0.0", | ||
"prettier": "^3.4.2", | ||
"tinyexec": "^0.3.1", | ||
"typescript": "^5.7.2", | ||
"vitest": "^2.1.8" | ||
}, | ||
"dependencies": { | ||
"steiger": "workspace:*" | ||
} | ||
} |
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,2 @@ | ||
// Do not add any other lines of code to this file! | ||
import '@total-typescript/ts-reset' |
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,23 @@ | ||
/** | ||
* Run this script on Mac or Linux when you update test snapshots to port these changes over to Windows snapshots. | ||
* | ||
* $ pnpm run update-windows-snapshots | ||
*/ | ||
|
||
import * as fs from 'node:fs/promises' | ||
import { dirname, join } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { replaceSymbols } from 'figures' | ||
|
||
const snapshotsFolder = join(dirname(fileURLToPath(import.meta.url)), '../tests/__snapshots__') | ||
|
||
// Go through each POSIX snapshot and replace the forward slashes in diagnostic paths with backslashes | ||
for (const file of await fs.readdir(snapshotsFolder)) { | ||
if (file.endsWith('-posix.txt')) { | ||
const windowsSnapshotName = file.slice(0, -'-posix.txt'.length) + '-windows.txt' | ||
const updatedSnapshot = replaceSymbols(await fs.readFile(join(snapshotsFolder, file), 'utf8'), { | ||
useFallback: true, | ||
}).replace(/(?<=┌.+)\//gm, '\\') | ||
await fs.writeFile(join(snapshotsFolder, windowsSnapshotName), updatedSnapshot) | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
integration-tests/tests/__snapshots__/smoke-stderr-posix.txt
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,45 @@ | ||
|
||
┌ src/entities/user/api/getUser.ts | ||
✘ Forbidden import from higher layer "app". | ||
│ | ||
└ fsd/forbidden-imports (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/forbidden-imports) | ||
|
||
┌ src/entities | ||
✘ Inconsistent pluralization of slice names. Prefer all plural names | ||
✔ Auto-fixable | ||
│ | ||
└ fsd/inconsistent-naming (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/inconsistent-naming) | ||
|
||
┌ src/entities/user | ||
✘ This slice has no references. Consider removing it. | ||
│ | ||
└ fsd/insignificant-slice (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/insignificant-slice) | ||
|
||
┌ src/entities/users | ||
✘ This slice has no references. Consider removing it. | ||
│ | ||
└ fsd/insignificant-slice (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/insignificant-slice) | ||
|
||
┌ src/entities/user/api/getUser.ts | ||
✘ Forbidden sidestep of public API when importing from "@/app/ui/App". | ||
│ | ||
└ fsd/no-public-api-sidestep (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-public-api-sidestep) | ||
|
||
┌ src/entities/user/ui/api | ||
✘ Having a folder with the name "api" inside a segment could be confusing because that name is commonly used for segments. Consider renaming it. | ||
│ | ||
└ fsd/no-reserved-folder-names (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-reserved-folder-names) | ||
|
||
┌ src/app/ui | ||
✘ Layer "app" should not have "ui" segment. | ||
│ | ||
└ fsd/no-ui-in-app (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app) | ||
|
||
┌ src/processes | ||
✘ Layer "processes" is deprecated, avoid using it | ||
│ | ||
└ fsd/no-processes (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-processes) | ||
|
||
──────────────────────────────────────────────────────── | ||
Found 8 errors (1 can be fixed automatically with --fix) | ||
|
45 changes: 45 additions & 0 deletions
45
integration-tests/tests/__snapshots__/smoke-stderr-windows.txt
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,45 @@ | ||
|
||
┌ src\entities\user\api\getUser.ts | ||
× Forbidden import from higher layer "app". | ||
│ | ||
└ fsd/forbidden-imports (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/forbidden-imports) | ||
|
||
┌ src\entities | ||
× Inconsistent pluralization of slice names. Prefer all plural names | ||
√ Auto-fixable | ||
│ | ||
└ fsd/inconsistent-naming (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/inconsistent-naming) | ||
|
||
┌ src\entities\user | ||
× This slice has no references. Consider removing it. | ||
│ | ||
└ fsd/insignificant-slice (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/insignificant-slice) | ||
|
||
┌ src\entities\users | ||
× This slice has no references. Consider removing it. | ||
│ | ||
└ fsd/insignificant-slice (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/insignificant-slice) | ||
|
||
┌ src\entities\user\api\getUser.ts | ||
× Forbidden sidestep of public API when importing from "@/app/ui/App". | ||
│ | ||
└ fsd/no-public-api-sidestep (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-public-api-sidestep) | ||
|
||
┌ src\entities\user\ui\api | ||
× Having a folder with the name "api" inside a segment could be confusing because that name is commonly used for segments. Consider renaming it. | ||
│ | ||
└ fsd/no-reserved-folder-names (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-reserved-folder-names) | ||
|
||
┌ src\app\ui | ||
× Layer "app" should not have "ui" segment. | ||
│ | ||
└ fsd/no-ui-in-app (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-ui-in-app) | ||
|
||
┌ src\processes | ||
× Layer "processes" is deprecated, avoid using it | ||
│ | ||
└ fsd/no-processes (https://github.com/feature-sliced/steiger/tree/master/packages/steiger-plugin-fsd/src/no-processes) | ||
|
||
──────────────────────────────────────────────────────── | ||
Found 8 errors (1 can be fixed automatically with --fix) | ||
|
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,24 @@ | ||
import * as fs from 'node:fs/promises' | ||
import os from 'node:os' | ||
import { dirname, join } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { exec } from 'tinyexec' | ||
|
||
import { expect, test } from 'vitest' | ||
|
||
import { getSteigerBinPath } from '../utils/get-bin-path.js' | ||
|
||
const temporaryDirectory = await fs.realpath(os.tmpdir()) | ||
const steiger = await getSteigerBinPath() | ||
const kitchenSinkExample = join(dirname(fileURLToPath(import.meta.url)), '../../examples/kitchen-sink-of-fsd-issues') | ||
const pathPlatform = os.platform() === 'win32' ? 'windows' : 'posix' | ||
|
||
test('basic functionality in the kitchen sink example project', async () => { | ||
const project = join(temporaryDirectory, 'smoke') | ||
await fs.rm(project, { recursive: true, force: true }) | ||
await fs.cp(kitchenSinkExample, project, { recursive: true }) | ||
|
||
const { stderr } = await exec('node', [steiger, 'src'], { nodeOptions: { cwd: project, env: { NO_COLOR: '1' } } }) | ||
|
||
await expect(stderr).toMatchFileSnapshot(join('__snapshots__', `smoke-stderr-${pathPlatform}.txt`)) | ||
}) |
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,7 @@ | ||
{ | ||
"extends": "@steiger/tsconfig/base.json", | ||
"include": ["./tests", "./reset.d.ts", "utils/get-bin-path.ts"], | ||
"compilerOptions": { | ||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json" | ||
} | ||
} |
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,22 @@ | ||
import { promises as fs } from 'node:fs' | ||
import * as process from 'node:process' | ||
import { dirname, join } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
import { getBinPath } from 'get-bin-path' | ||
|
||
/** | ||
* Resolve the full path to the built JS file of Steiger. | ||
* | ||
* Rejects if the file doesn't exist. | ||
*/ | ||
export async function getSteigerBinPath() { | ||
const steiger = (await getBinPath({ cwd: join(dirname(fileURLToPath(import.meta.url)), '../../packages/steiger') }))! | ||
try { | ||
await fs.stat(steiger) | ||
} catch { | ||
console.error('Run `turbo build` before running integration tests') | ||
process.exit(1) | ||
} | ||
|
||
return steiger | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I removed this part while I was adding the sorting because I found several return statements to be confusing and because I believe this isn't that impactful from the performance perspective. The empty array will simply get processed as any other array, with no work done on it