-
Notifications
You must be signed in to change notification settings - Fork 44
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
test: Refactor test set up for readability #810
Merged
rmi22186
merged 8 commits into
ci/SQDSDKS-5780-cross-browser-testing
from
ci/SQDSDKS-5960-refactor-tests
Dec 1, 2023
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4c7a90c
Refactor test files for easier readability
rmi22186 652ca20
add comments
rmi22186 d83d7e7
Rename files
rmi22186 25d7f8b
Revise setup to make it more typesafe
alexs-mparticle a1d4845
Update src/sdkRuntimeModels.ts
rmi22186 882d91b
Turn comments
rmi22186 1288b6f
Apply suggestions from code review
rmi22186 30e89fd
Remove -w flag from build:cbt
rmi22186 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
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
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,31 @@ | ||
// Import set up logic | ||
import './config/setup'; | ||
|
||
// Import each test module | ||
import './tests-core-sdk'; | ||
import './tests-batchUploader'; | ||
import './tests-beaconUpload'; | ||
import './tests-kit-blocking'; | ||
import './tests-persistence'; | ||
import './tests-forwarders'; | ||
import './tests-helpers'; | ||
import './tests-identity'; | ||
import './tests-event-logging'; | ||
import './tests-eCommerce'; | ||
import './tests-cookie-syncing'; | ||
import './tests-identities-attributes'; | ||
import './tests-native-sdk'; | ||
import './tests-consent'; | ||
import './tests-serverModel'; | ||
import './tests-mockBatchCreator'; | ||
import './tests-mParticleUser'; | ||
import './tests-self-hosting-specific'; | ||
import './tests-runtimeToBatchEventsDTO'; | ||
import './tests-apiClient'; | ||
import './tests-mparticle-instance-manager'; | ||
import './tests-queue-public-methods'; | ||
import './tests-validators'; | ||
import './tests-utils'; | ||
import './tests-session-manager'; | ||
import './tests-store'; | ||
import './tests-config-api-client'; |
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,38 @@ | ||
import { MPConfig, workspaceToken } from './constants'; | ||
import { MParticleWebSDK } from '../../../src/sdkRuntimeModels'; | ||
|
||
declare global { | ||
interface Window { | ||
mParticle: MParticleWebSDK; | ||
} | ||
} | ||
|
||
var userApi = null; | ||
rmi22186 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
window.mParticle._isTestEnv = true; | ||
|
||
beforeEach(function() { | ||
// mocha can't clean up after itself, so this lets | ||
// tests mock the current user and restores in between runs. | ||
if (!userApi) { | ||
userApi = window.mParticle.getInstance().Identity.getCurrentUser; | ||
} else { | ||
window.mParticle.getInstance().Identity.getCurrentUser = userApi; | ||
} | ||
|
||
window.mParticle.config = { | ||
workspaceToken: workspaceToken, | ||
logLevel: 'none', | ||
kitConfigs: [], | ||
requestConfig: false, | ||
isDevelopmentMode: false, | ||
flags: { | ||
eventBatchingIntervalMillis: 0, | ||
} | ||
}; | ||
|
||
// This is to tell the resetPersistence method that we are in a test environment | ||
// It should probably be refactored to be included as an argument | ||
window.mParticle._resetForTests(MPConfig); | ||
delete window.mParticle._instances['default_instance']; | ||
}); |
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
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
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
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
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.
As per our conversation this morning, I thought we were just going to call this
index.ts
?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.
Oh I thought we were just removing the underscore. If the idea is to eventually rename things to
module.spec.ts
like you have forvault.spec.ts
, then once we have things higher alphabetically, it's better to keep it the underscore to keep it at the top of the folder.