Skip to content

Commit

Permalink
update to use chai via import
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Jul 9, 2024
1 parent a44d64c commit 914b3f2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 38 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/bluebird": "^3.5.38",
"@types/chai": "^4.3.5",
"@types/chai-as-promised": "^7.1.5",
"@types/lodash": "^4.14.196",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.7",
"@types/sinon": "^17.0.0",
"@types/sinon-chai": "^3.2.9",
"@types/teen_process": "^2.0.2",
"chai": "^4.1.2",
"chai": "^5.1.1",
"chai-as-promised": "^8.0.0",
"conventional-changelog-conventionalcommits": "^8.0.0",
"mocha": "^10.0.0",
Expand Down
15 changes: 9 additions & 6 deletions test/e2e/commands/file-movement-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { remote as wdio } from 'webdriverio';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import path from 'path';
import { tempDir, fs } from 'appium/support';
import { isAdmin } from '../../../lib/installer';
import { TEST_HOST, TEST_PORT } from '../constants';


chai.should();
chai.use(chaiAsPromised);


const TEST_CAPS = {
platformName: 'Windows',
'appium:automationName': 'windows',
Expand All @@ -27,6 +21,15 @@ const WDIO_OPTS = {
describe('file movement', function () {
let driver;
let remotePath;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);
});

beforeEach(async function () {
if (process.env.CI || !await isAdmin()) {
Expand Down
15 changes: 9 additions & 6 deletions test/e2e/commands/winapi-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { commands } from '../../../lib/commands/gestures';
import log from '../../../lib/logger';


chai.should();
chai.use(chaiAsPromised);

describe('winapi', function () {
before(function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);
commands.log = log;
});

after(function () {
delete commands.log;
});
Expand Down
14 changes: 9 additions & 5 deletions test/e2e/driver-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { remote as wdio } from 'webdriverio';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { isAdmin } from '../../lib/installer';
import { TEST_HOST, TEST_PORT } from './constants';

chai.should();
chai.use(chaiAsPromised);


const TEST_CAPS = {
platformName: 'Windows',
Expand All @@ -23,6 +18,15 @@ const WDIO_OPTS = {

describe('Driver', function () {
let driver;
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);
});

beforeEach(async function () {
if (process.env.CI || !await isAdmin()) {
Expand Down
13 changes: 9 additions & 4 deletions test/e2e/installer-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { setupWAD, downloadWAD, isAdmin } from '../../lib/installer';
import { fs } from 'appium/support';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';

chai.should();
chai.use(chaiAsPromised);

describe('installer', function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);
});

it('should download the distributable', async function () {
const tmpPath = await downloadWAD();
Expand Down
15 changes: 9 additions & 6 deletions test/unit/driver-specs.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// transpile:mocha

import WindowsDriver from '../../lib/driver';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';
import B from 'bluebird';
import { system } from 'appium/support';


chai.should();
chai.use(chaiAsPromised);

describe('driver.js', function () {
let isWindowsStub;
before(function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);

isWindowsStub = sinon.stub(system, 'isWindows').returns(true);
});
after(function () {
Expand Down
14 changes: 9 additions & 5 deletions test/unit/installer-specs.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { setupWAD } from '../../lib/installer';
import { system } from 'appium/support';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';

chai.should();
chai.use(chaiAsPromised);

describe('downloading WAD', function () {
let isWindowsStub;
before(function () {
let chai;

before(async function () {
chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');

should = chai.should();
chai.use(chaiAsPromised.default);

isWindowsStub = sinon.stub(system, 'isWindows').returns(false);
});
after(function () {
Expand Down
11 changes: 8 additions & 3 deletions test/unit/registry-specs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { parseRegQueryOutput } from '../../lib/registry';
import chai from 'chai';

chai.should();

describe('registry', function () {
let chai;

before(async function () {
chai = await import('chai');

should = chai.should();
});

it('should parse reg query output', function () {
const output = `
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AddressBook
Expand Down

0 comments on commit 914b3f2

Please sign in to comment.