-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat/WIP: e2e sibling test #795
Open
lucas-zimerman
wants to merge
45
commits into
main
Choose a base branch
from
test/sibling
base: main
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.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
32965f2
idea of e2e sibling test
lucas-zimerman 691d2df
add e2e tests (WIP)
lucas-zimerman d5f3bbf
use E2E flag
lucas-zimerman 7b5c8db
remove tests
lucas-zimerman 8f47398
set e2e test name
lucas-zimerman 6e6fbea
setup yalc
lucas-zimerman a26b620
disable flaky test
lucas-zimerman fa16b47
add safe check on getting the package manager version
lucas-zimerman b5f3fb4
message and stack
lucas-zimerman c42b471
test
lucas-zimerman 4955a1d
test
lucas-zimerman a6d2e97
add path log
lucas-zimerman e94c293
test
lucas-zimerman cd04077
check if corepack will sort this
lucas-zimerman 429dbbd
add ref
lucas-zimerman d4c885d
test add corepack check
lucas-zimerman b1ac473
lets log artifacts if they fail
lucas-zimerman 9c5b450
correct log
lucas-zimerman 3d5dcb5
correct log
lucas-zimerman 95627cb
Merge branch 'main' of https://github.com/getsentry/sentry-capacitor …
lucas-zimerman 0d6a976
use newer upload artifact
lucas-zimerman 142f78b
use static version
lucas-zimerman bcd9b8c
add corepack check
lucas-zimerman a58f63d
install corepack
lucas-zimerman 960b88f
test
lucas-zimerman 2a44287
sync path
lucas-zimerman 6428a88
verbose error
lucas-zimerman d326411
more verbose error
lucas-zimerman cebc4b4
null safety
lucas-zimerman 49b8e40
sync env
lucas-zimerman df6ad32
remove corepack setup
lucas-zimerman 59f97b3
only pass PATH
lucas-zimerman d021658
compare env
lucas-zimerman 3d4f19e
remove test and use node
lucas-zimerman 47eeac8
test - hide global yarn
lucas-zimerman 3e258d6
fix path on install script
lucas-zimerman b40bded
Merge branch 'main' of https://github.com/getsentry/sentry-capacitor …
lucas-zimerman 11af74f
reduce complexity and use default npm
lucas-zimerman a168a00
test cache
lucas-zimerman de0a0d8
remove todo
lucas-zimerman b037484
use different e2e log check
lucas-zimerman de70877
nit
lucas-zimerman bdcf2fc
Merge branch 'main' into test/sibling
lucas-zimerman ab94537
remove unused code, clear logs
lucas-zimerman 9ebf608
nit
lucas-zimerman 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
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
2 changes: 2 additions & 0 deletions
2
e2e-test/scripts/siblingsTests/npm_default/packagemanager.package.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,2 @@ | ||
{ | ||
} |
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,11 @@ | ||
{ | ||
"name": "2e2-sibling-test", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"_comment": "postinstall scripts are not called from file packages so we copy the same post install from sentry capacitor", | ||
"postinstall": "node node_modules/@sentry/capacitor/scripts/check-siblings.js" | ||
}, | ||
"dependencies": { | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
e2e-test/scripts/siblingsTests/yarn_v1/packagemanager.package.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,3 @@ | ||
{ | ||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} |
3 changes: 3 additions & 0 deletions
3
e2e-test/scripts/siblingsTests/yarn_v3/packagemanager.package.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,3 @@ | ||
{ | ||
"packageManager": "yarn@3.8.6" | ||
} |
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,16 @@ | ||
module.exports = { | ||
testEnvironment: "node", | ||
transform: { | ||
"^.+\\.(ts)$": "ts-jest" | ||
}, | ||
setupFilesAfterEnv: ["jest-extended/all"], | ||
globals: { | ||
"__DEV__": true, | ||
"ts-jest": { | ||
tsconfig: "./tsconfig.json", | ||
diagnostics: false | ||
} | ||
}, | ||
moduleFileExtensions: ["ts", "js"], | ||
testMatch: ["**/test/scripts/**/*.test.(ts|tsx)"], | ||
}; |
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,23 @@ | ||
#!/bin/bash | ||
|
||
# Publish with yalc | ||
yalc publish --sig | ||
|
||
# Navigate to siblingsTests and publish without modifying package.json | ||
cd e2e-test/scripts/siblingsTests/ | ||
|
||
rm -r .yalc | ||
rm -r node_modules | ||
|
||
cp package.json package.json.bak | ||
|
||
yalc add @sentry/capacitor | ||
|
||
rm yalc.lock | ||
rm package.json | ||
mv package.json.bak package.json | ||
|
||
cd ../../.. | ||
|
||
# Run Jest | ||
jest -c jest.e2e.config.js |
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,118 @@ | ||
import path from 'path'; | ||
const { execSync } = require("child_process"); | ||
|
||
import { ClearE2ETestFolder, CreateE2EPackage, CreateE2EStartPackage, e2ePath, GetInitialE2EPackage, GetLogs, GetPackageManagerVersion, InstallSDK, InvalidSentrySiblingVersion, readJsonOrEmpty, SDKPath, ValidSentrySiblingVersion } from './check-siblingsHelper'; | ||
|
||
const CapacitorInstallArg = `file:${SDKPath}` | ||
|
||
describe('NPM tests', () => { | ||
const npme2ePath = path.join(e2ePath, 'npm_default'); | ||
const PackageMangerVersion = execSync("npm --version").toString().trim(); | ||
|
||
describe('new Install', () => { | ||
test('no warnings when correct sibling is installed', async () => { | ||
// Setup. | ||
const siblingVersion = ValidSentrySiblingVersion(); | ||
|
||
const testPath = path.join(npme2ePath, 'newInstallCorrectSibling'); | ||
const packageJsonPath = path.join(testPath, 'package.json'); | ||
|
||
ClearE2ETestFolder(testPath); | ||
CreateE2EPackage(testPath); | ||
|
||
expect(GetPackageManagerVersion('npm', testPath)).toBe(PackageMangerVersion); | ||
|
||
const expectedPackageJson = { | ||
...GetInitialE2EPackage(testPath), | ||
dependencies: { | ||
'@sentry/capacitor': 'file:../../.yalc/@sentry/capacitor', | ||
'@sentry/angular': siblingVersion | ||
} | ||
}; | ||
|
||
|
||
// Test | ||
const result = InstallSDK('npm',['install', '--save-exact', '--foreground-scripts', CapacitorInstallArg, `@sentry/angular@${siblingVersion}`], testPath); | ||
const packageJson = readJsonOrEmpty(packageJsonPath); | ||
const e2eLogs = GetLogs(testPath); | ||
|
||
// Expect | ||
expect(result.status).toBe(0); | ||
expect(packageJson).toEqual(expectedPackageJson); | ||
expect(e2eLogs).toContain('E2E_TEST: OK'); | ||
}); | ||
}); | ||
|
||
describe('update packages', () => { | ||
test('no warnings when correct sibling are updated', async () => { | ||
// Setup. | ||
const siblingVersion = ValidSentrySiblingVersion(); | ||
|
||
const testPath = path.join(npme2ePath, 'updateCorrectSibling'); | ||
const packageJsonPath = path.join(testPath, 'package.json'); | ||
const dependenciesJson = { | ||
dependencies: { | ||
'@sentry/capacitor': CapacitorInstallArg, | ||
'@sentry/angular': siblingVersion | ||
} | ||
}; | ||
|
||
ClearE2ETestFolder(testPath); | ||
CreateE2EStartPackage(testPath, dependenciesJson); | ||
CreateE2EPackage(testPath); | ||
expect(GetPackageManagerVersion('npm', testPath)).toBe(PackageMangerVersion); | ||
|
||
const expectedPackageJson = { | ||
...GetInitialE2EPackage(testPath), | ||
...dependenciesJson | ||
}; | ||
|
||
// Test | ||
const result = InstallSDK('npm',['install'], testPath); | ||
const packageJson = readJsonOrEmpty(packageJsonPath); | ||
const e2eLogs = GetLogs(testPath); | ||
|
||
// Expect | ||
expect(result.status).toBe(0); | ||
expect(packageJson).toEqual(expectedPackageJson); | ||
expect(e2eLogs).toContain('E2E_TEST: OK'); | ||
}); | ||
|
||
test('warns when incorrect sibling is installed', async () => { | ||
// Setup. | ||
const siblingVersion = InvalidSentrySiblingVersion(); | ||
|
||
const testPath = path.join(npme2ePath, 'updateInorrectSibling'); | ||
const packageJsonPath = path.join(testPath, 'package.json'); | ||
const dependenciesJson = { | ||
dependencies: { | ||
'@sentry/capacitor': CapacitorInstallArg, | ||
'@sentry/angular': siblingVersion | ||
} | ||
}; | ||
|
||
ClearE2ETestFolder(testPath); | ||
CreateE2EStartPackage(testPath, dependenciesJson); | ||
CreateE2EPackage(testPath); | ||
expect(GetPackageManagerVersion('npm', testPath)).toBe(PackageMangerVersion); | ||
|
||
const expectedPackageJson = { | ||
...GetInitialE2EPackage(testPath), | ||
...dependenciesJson | ||
}; | ||
|
||
// Test | ||
const result = InstallSDK('npm', ['install'], testPath); | ||
const packageJson = readJsonOrEmpty(packageJsonPath); | ||
const logs = GetLogs(testPath).join('\n'); | ||
|
||
// Expect | ||
expect(result.status).toBe(1); | ||
expect(packageJson).toEqual(expectedPackageJson); | ||
expect(logs).toContain('E2E_TEST: Incompatibility found'); | ||
expect(logs).toContain(`⚠️ This version of Sentry Capacitor is incompatible with the following installed packages: | ||
@sentry/angular version ${siblingVersion}`); | ||
expect(logs).toContain(`npm install --save-exact @sentry/angular@${ValidSentrySiblingVersion()} --update-sentry-capacitor`); | ||
}); | ||
}); | ||
}); |
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.
We create this folder because it loads faster than pointing yarn to install the root project (10 minutes vs 5 seconds) on the sibling tests
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.
By this folder, do you mean
e2e-test/scripts/siblingsTests
?