Skip to content

Commit

Permalink
CommonJS Support (#214)
Browse files Browse the repository at this point in the history
- Removed external dependency for download
- Use https to download and external module compressing to extract
- Reworked tests
  • Loading branch information
diemol authored Oct 15, 2023
1 parent a781410 commit 02f933f
Show file tree
Hide file tree
Showing 8 changed files with 526 additions and 1,087 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ build
.idea/
.DS_Store
.vscode
sc-loader
5 changes: 3 additions & 2 deletions e2e/sc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SauceLabs from '../build';

const ID = process.env.GITHUB_RUN_ID ?? '(local)';
// Only run the test when the env var is present
// in GitHub Actions, otherwise it fails for untrusted PRs/
// in GitHub Actions, otherwise it fails for untrusted PRs
const SKIP_TEST = process.env.GITHUB_RUN_ID && !process.env.SAUCE_USERNAME;

jest.setTimeout(60 * 1000); // 60s should be sufficient to boot SC
Expand All @@ -11,10 +11,11 @@ jest.setTimeout(60 * 1000); // 60s should be sufficient to boot SC
* unmock
*/
jest
.unmock('@xhmikosr/downloader')
.unmock('https')
.unmock('form-data')
.unmock('got')
.unmock('yargs')
.unmock('compressing')
.unmock('zlib');

test('should not be able to run Sauce Connect due to invalid credentials', async () => {
Expand Down
44 changes: 4 additions & 40 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,16 @@
const esModules = [
// got and dependencies
'got',
'p-cancelable',
'@szmarczak/http-timer',
'lowercase-keys',
'@sindresorhus/is',
'cacheable-request',
'normalize-url',
'responselike',
'cacheable-request',
'mimic-response',
'form-data-encoder',
'cacheable-lookup',
// @xhmikosr/downloader and dependencies
'@xhmikosr/downloader',
'@xhmikosr/archive-type',
'file-type',
'strtok3',
'peek-readable',
'token-types',
'@xhmikosr/decompress',
'@xhmikosr/decompress-tar',
'is-stream',
'filenamify',
'trim-repeated',
'escape-string-regexp',
'filename-reserved-regex',
'strip-outer',
'p-event',
'p-timeout',
];

module.exports = {
testMatch: ['<rootDir>/tests/**/*.test.js'],
testPathIgnorePatterns: ['/node_modules/'],
coverageDirectory: './coverage/',
collectCoverage: true,
coverageThreshold: {
global: {
branches: 93,
functions: 100,
lines: 98,
statements: 98,
branches: 94,
functions: 98,
lines: 97,
statements: 97,
},
},
testEnvironment: 'node',
restoreMocks: true,
transformIgnorePatterns: esModules.length
? [`/node_modules/(?!${esModules.join('|')})`]
: [],
};
Loading

0 comments on commit 02f933f

Please sign in to comment.