Skip to content

Commit

Permalink
test: split test configs in unit and e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emilianofant-split committed Jun 23, 2021
1 parent 5ec9566 commit 50cfd8a
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 2 deletions.
10 changes: 10 additions & 0 deletions e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
name: 'e2e',
displayName: 'E2E Tests',
preset: 'ts-jest',
// A list of paths to directories that
// Jest should use to search for files in
roots: [
'<rootDir>',
],
};
20 changes: 20 additions & 0 deletions e2e/synchroniser.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('Synchroniser e2e', () => {
// Mock fetch /splitChanges and /segmentChanges
it('Fetches splits from Split API', () => {
expect(true).toBe(true);
});

// Run Synchonizer once
// Assert if the splits and segment objects were stored properly

// Either run SDK in consumer mode or mock events and impressions in Redis
// const sdk = SplitFactory({...})
// const client = sdk.client();
// client.getTreatment
// client.track

// Run Synchonizer again

// Assert if the impressions and events were removed from redis and that /impressions and /event endpoints
//were properly called.
});
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ module.exports = {
preset: 'ts-jest',

// Test files are .js and .ts files inside of __tests__ folders and with a suffix of .test or .spec
testMatch: ['<rootDir>/src/**/__tests__/**/?(*.)+(spec|test).[jt]s'],
testMatch: [
'<rootDir>/src/**/__tests__/**/?(*.)+(spec|test).[jt]s',
'<rootDir>/e2e/?(*.)+(spec|test).[jt]s',
],

// Required when using Split dependencies via GitHub
// `"@splitsoftware/splitio-commons": "github:splitio/javascript-commons#branch_name",`
Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"check:lint": "eslint src --ext .js,.ts",
"check:types": "tsc --noEmit",
"build": "rimraf dist && tsc -outDir dist --importHelpers && scripts/build_cjs_replace_imports.sh && npm run add-version && scripts/make_cli.sh",
"test": "clear && jest --verbose"
"test:unit": "jest --projects src/",
"test:e2e": "jest --projects e2e/",
"test": "jest --verbose"
},
"keywords": [],
"author": "",
Expand All @@ -37,6 +39,7 @@
"fetch-mock-jest": "^1.5.1",
"husky": "^6.0.0",
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"replace": "^1.2.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
Expand Down
16 changes: 16 additions & 0 deletions src/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
name: 'unit',
displayName: 'Unit Tests',
preset: 'ts-jest',
// A list of paths to directories that
// Jest should use to search for files in
roots: [
'<rootDir>',
],
// Test files are .js and .ts files inside of __tests__ folders and with a suffix of .test or .spec
testMatch: ['./**/__tests__/**/?(*.)+(spec|test).[jt]s'],
// Required when using Split dependencies via GitHub
// `"@splitsoftware/splitio-commons": "github:splitio/javascript-commons#branch_name",`
transform: { '../node_modules/@splitsoftware/.+\\.(j|t)s$': 'ts-jest' },
transformIgnorePatterns: ['/node_modules/(?!@splitsoftware/.*)'],
};

0 comments on commit 50cfd8a

Please sign in to comment.