Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: saucelabs/node-saucectl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.164.0
Choose a base ref
...
head repository: saucelabs/node-saucectl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.164.1
Choose a head ref
  • 3 commits
  • 15 files changed
  • 2 contributors

Commits on Oct 11, 2023

  1. build!: upgrade Node.js 20 (#26)

    * build!: bump ECMA from 2018 to 2022
    
    * deps!: update runtime dependencies
    
    * docs: outdated lingo
    
    * ci: pipeline hygiene
    
    * build: upgrade Node.js 20
    
    * deps: bump dev dependencies
    
    * chore: clean up redundant style setting
    
    * ci: remove npm cache instructions
    Alex Plischke authored Oct 11, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3c34e86 View commit details

Commits on Oct 20, 2023

  1. style: format all code with prettier (#27)

    * style: format all code with prettier
    
    * build: use more explicit test steps
    
    * ci: remove redundant job
    
    * ci: rename extremely confusing job name
    
    * ci: don't cache, since there's no lock file
    Alex Plischke authored Oct 20, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9635a35 View commit details

Commits on Oct 23, 2023

  1. 0.164.1

    oss-sauce-bot committed Oct 23, 2023
    Copy the full SHA
    74725e7 View commit details
Showing with 275 additions and 221 deletions.
  1. +0 −13 .editorconfig
  2. +1 −0 .eslintignore
  3. +15 −0 .eslintrc
  4. +0 −19 .eslintrc.js
  5. +18 −8 .github/workflows/release.yml
  6. +16 −18 .github/workflows/test.yml
  7. +1 −1 .nvmrc
  8. +1 −0 .prettierignore
  9. +3 −0 .prettierrc
  10. +1 −1 README.md
  11. +88 −74 __tests__/main.test.js
  12. +94 −60 index.js
  13. +9 −4 install.js
  14. +10 −10 jest.config.js
  15. +18 −13 package.json
13 changes: 0 additions & 13 deletions .editorconfig

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
15 changes: 15 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"root": true,
"env": {
"es2022": true,
"node": true,
"jest/globals": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
"plugins": [
"jest"
]
}
19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

26 changes: 18 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: saucectl pipeline
# This workflow is triggered by https://github.com/saucelabs/saucectl on release.
name: Release

on: [repository_dispatch]

@@ -13,32 +12,43 @@ jobs:
steps:
- name: Event Information
run: echo "Event '${{ github.event.action }}' received from '${{ github.event.client_payload.version }}'"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm install

- name: NPM Setup
run: |
npm set registry "https://registry.npmjs.org/"
npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
npm whoami
- name: Git Setup
run: |
git config --global user.name "oss-sauce-bot"
git config --global user.email "66365630+oss-sauce-bot@users.noreply.github.com"
- if: github.event.client_payload.version != ''
run: npx np ${{ github.event.client_payload.version }}

post-deploy-install:
needs: ["deploy"]
if: github.event.client_payload.version != ''
runs-on: ubuntu-latest
steps:
- name: Event Information
run: echo "Event '${{ github.event.action }}' received from '${{ github.event.client_payload.version }}'"

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: '.nvmrc'

- name: Install saucectl
run: npm install saucectl@${{ github.event.client_payload.version }}
34 changes: 16 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: saucectl pipeline
name: Test

on:
pull_request:
@@ -9,24 +7,24 @@ on:
- main

jobs:
deploy:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
- run: npm test
- name: Checkout
uses: actions/checkout@v4

deploy-with-github_token:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm install
node-version-file: '.nvmrc'

- name: Install Dependencies
run: npm install
env:
GITHUB_TOKEN: ${{ github.token }}
- run: npm test

- name: Lint
run: npm run lint

- name: Test
run: npm test
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.1.0
v20
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/lib
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Node.js saucectl Wrapper ![build](https://github.com/saucelabs/node-saucectl/workflows/saucectl%20pipeline/badge.svg)
========================

Node.js wrapper for saucectl: Sauce Labs Testrunner Toolkit.
Node.js wrapper for [saucectl](https://github.com/saucelabs/saucectl).

## Install

162 changes: 88 additions & 74 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jest.mock('child_process')
jest.mock('child_process');
const main = require('../');
const childProcess = require('child_process');
const { EventEmitter } = require('events');
@@ -13,87 +13,101 @@ const originalOs = process.platform;
const originalArch = process.arch;

describe('main', function () {
let exitSpy, mockSpawnEventEmitter;
beforeAll(function () {
childProcess.spawn.mockImplementation(() => {
mockSpawnEventEmitter = new EventEmitter();
return mockSpawnEventEmitter;
});
exitSpy = jest.spyOn(process, 'exit');
exitSpy.mockImplementation(() => { });
});
let exitSpy, mockSpawnEventEmitter;
beforeAll(function () {
childProcess.spawn.mockImplementation(() => {
mockSpawnEventEmitter = new EventEmitter();
return mockSpawnEventEmitter;
});
exitSpy = jest.spyOn(process, 'exit');
exitSpy.mockImplementation(() => {});
});

beforeEach(() => {
BinWrapper.mockClear();
beforeEach(() => {
BinWrapper.mockClear();

Object.defineProperty(process, 'platform', { value: 'darwin' });
Object.defineProperty(process, 'arch', { value: 'arm64' });
Object.defineProperty(process, 'platform', { value: 'darwin' });
Object.defineProperty(process, 'arch', { value: 'arm64' });

mockSrc = jest.fn();
mockSrc = jest.fn();

BinWrapper.mockReturnValue({
use: jest.fn(),
dest: jest.fn(),
src: mockSrc,
run: jest.fn(),
});
});
afterEach(() => {
jest.clearAllMocks();
BinWrapper.mockReturnValue({
use: jest.fn(),
dest: jest.fn(),
src: mockSrc,
run: jest.fn(),
});
});
afterEach(() => {
jest.clearAllMocks();

Object.defineProperty(process, 'platform', { value: originalOs });
Object.defineProperty(process, 'arch', { value: originalArch });
});
Object.defineProperty(process, 'platform', { value: originalOs });
Object.defineProperty(process, 'arch', { value: originalArch });
});

test('should run the executable', async function () {
const bin = {
run: jest.fn().mockReturnValue(Promise.resolve(0)),
path: jest.fn().mockReturnValue('/bin/saucectl')
}
await main(bin, ['bar', '--foo'])
expect(bin.run).toBeCalledTimes(1)
expect(childProcess.spawn).toBeCalledWith('/bin/saucectl', ['bar', '--foo'], expect.any(Object))
mockSpawnEventEmitter.emit('exit', 0);
expect(exitSpy.mock.calls).toEqual([[0]]);
});
test('should display carry the exitCode', async function () {
const bin = {
run: jest.fn().mockReturnValue(Promise.resolve(1)),
path: jest.fn().mockReturnValue('/bin/saucectl')
}
await main(bin, ['bar', '--foo'])
expect(bin.run).toBeCalledTimes(1)
expect(childProcess.spawn).toBeCalledWith('/bin/saucectl', ['bar', '--foo'], expect.any(Object))
expect(exitSpy.mock.calls).toEqual([[1]]);
});
describe('.binWrapper', function () {
test('should create a binary wrapper', async function () {
await main.binWrapper();
test('should run the executable', async function () {
const bin = {
run: jest.fn().mockReturnValue(Promise.resolve(0)),
path: jest.fn().mockReturnValue('/bin/saucectl'),
};
await main(bin, ['bar', '--foo']);
expect(bin.run).toHaveBeenCalledTimes(1);
expect(childProcess.spawn).toHaveBeenCalledWith(
'/bin/saucectl',
['bar', '--foo'],
expect.any(Object),
);
mockSpawnEventEmitter.emit('exit', 0);
expect(exitSpy.mock.calls).toEqual([[0]]);
});
test('should display carry the exitCode', async function () {
const bin = {
run: jest.fn().mockReturnValue(Promise.resolve(1)),
path: jest.fn().mockReturnValue('/bin/saucectl'),
};
await main(bin, ['bar', '--foo']);
expect(bin.run).toHaveBeenCalledTimes(1);
expect(childProcess.spawn).toHaveBeenCalledWith(
'/bin/saucectl',
['bar', '--foo'],
expect.any(Object),
);
expect(exitSpy.mock.calls).toEqual([[1]]);
});
describe('.binWrapper', function () {
test('should create a binary wrapper', async function () {
await main.binWrapper();

expect(mockSrc.mock.calls).toEqual([
[
'https://github.com/saucelabs/saucectl/releases/download/v{{version}}/saucectl_{{version}}_mac_arm64.tar.gz'.replaceAll('{{version}}', packageJson.version),
'darwin',
'arm64',
]
]);
});
test('should respect the SAUCECTL_INSTALL_BINARY wrapper', async function () {
await main.binWrapper('http://some-fake-url');
expect(mockSrc.mock.calls).toEqual([
[
'https://github.com/saucelabs/saucectl/releases/download/v{{version}}/saucectl_{{version}}_mac_arm64.tar.gz'.replaceAll(
'{{version}}',
packageJson.version,
),
'darwin',
'arm64',
],
]);
});
test('should respect the SAUCECTL_INSTALL_BINARY wrapper', async function () {
await main.binWrapper('http://some-fake-url');

expect(mockSrc).toMatchSnapshot();
});
expect(mockSrc).toMatchSnapshot();
});

test('should respect the SAUCECTL_INSTALL_BINARY_MIRROR wrapper', async function () {
await main.binWrapper(null, 'https://some-fake-mirror-url');
test('should respect the SAUCECTL_INSTALL_BINARY_MIRROR wrapper', async function () {
await main.binWrapper(null, 'https://some-fake-mirror-url');

expect(mockSrc.mock.calls).toEqual([
[
'https://some-fake-mirror-url/v{{version}}/saucectl_{{version}}_mac_arm64.tar.gz'.replaceAll('{{version}}', packageJson.version),
'darwin',
'arm64',
]
]);
});
});
expect(mockSrc.mock.calls).toEqual([
[
'https://some-fake-mirror-url/v{{version}}/saucectl_{{version}}_mac_arm64.tar.gz'.replaceAll(
'{{version}}',
packageJson.version,
),
'darwin',
'arm64',
],
]);
});
});
});
Loading