Skip to content

Commit

Permalink
Merge pull request #1122 from forcedotcom/sm/test-naming
Browse files Browse the repository at this point in the history
Sm/test-naming
  • Loading branch information
mshanemc authored Aug 7, 2024
2 parents 659e490 + 00155a3 commit 4bf9406
Show file tree
Hide file tree
Showing 59 changed files with 14 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
command: 'yarn test:nuts'
os: ${{ matrix.os }}
useCache: false
# remove the test folder for sfdx-core
preBuildCommands: 'shx rm -rf test'
preSwapCommands: 'yarn upgrade @jsforce/jsforce-node@latest; npx yarn-deduplicate; yarn install'
preExternalBuildCommands: 'shx rm -rf node_modules/@salesforce/core/node_modules/@jsforce/jsforce-node shx rm -rf node_modules/@salesforce/sf-plugins-core/node_modules/@salesforce/core node_modules/@salesforce/cli-plugins-testkit/node_modules/@salesforce/core node_modules/@salesforce/source-tracking/node_modules/@salesforce/core node_modules/@salesforce/source-deploy-retrieve/node_modules/@salesforce/core node_modules/@salesforce/apex-node/node_modules/@salesforce/core'
secrets: inherit
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require": "test/init.js, ts-node/register, source-map-support/register",
"require": "ts-node/register, source-map-support/register",
"watch-extensions": "ts",
"watch-files": ["src", "test"],
"recursive": true,
Expand Down
2 changes: 1 addition & 1 deletion .sfdevrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"test": {
"testsPath": "test/**/*Test.ts"
"testsPath": "test/unit/**/*.test.ts"
},
"wireit": {
"compile": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"output": []
},
"test:only": {
"command": "nyc mocha \"test/**/*Test.ts\"",
"command": "nyc mocha \"test/unit/**/*.test.ts\"",
"env": {
"FORCE_COLOR": "2"
},
Expand Down Expand Up @@ -182,4 +182,4 @@
"command": "tsc -p typedocExamples"
}
}
}
}
8 changes: 0 additions & 8 deletions test/init.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@salesforce/dev-config/tsconfig-test-strict",
"include": ["nut/**/*.ts", "unit/**/*.ts", "perf/**/*.ts", "nut/configFileConcurrency.nut.ts"],
"include": ["nut/**/*.ts", "unit/**/*.ts", "perf/**/*.ts"],
"compilerOptions": {
"noEmit": true,
"skipLibCheck": true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('TTLConfig', () => {
it('should return the latest entry', async () => {
const config = await TestConfig.create();
config.set('1', { one: 'one' });
await sleep(1000);
await sleep(200);
config.set('2', { two: 'two' });
const latest = config.getLatestEntry();
expect(latest).to.deep.equal(['2', config.get('2')]);
Expand All @@ -68,7 +68,7 @@ describe('TTLConfig', () => {
it('should return the key of the latest entry', async () => {
const config = await TestConfig.create();
config.set('1', { one: 'one' });
await sleep(1000);
await sleep(200);
config.set('2', { two: 'two' });
const latest = config.getLatestKey();
expect(latest).to.equal('2');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/unit/loggerTest.ts → test/unit/logger/logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import { expect, config as chaiConfig } from 'chai';
import { isString } from '@salesforce/ts-types';
import { Logger, LoggerLevel, computeLevel } from '../../src/logger/logger';
import { shouldThrowSync, TestContext } from '../../src/testSetup';
import { Logger, LoggerLevel, computeLevel } from '../../../src/logger/logger';
import { shouldThrowSync, TestContext } from '../../../src/testSetup';

// NOTE: These tests still use 'await' which is how it use to work and were left to make
// sure we didn't regress the way they were used.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/unit/sfErrorTest.ts → test/unit/sfError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ describe('SfError', () => {
it('returned `name:message` when no cause', () => {
const err = new SfError('test');
expect(inspect(err)).to.include('SfError: test');
expect(inspect(err)).to.include('sfErrorTest.ts');
expect(inspect(err)).to.include('sfError.test.ts');
// there's always 1 cause from the `cause:` property, even if undefined
expect(inspect(err)?.match(causeRegex)).to.have.lengthOf(1);
});
it('1 cause', () => {
const nestedError = new Error('nested');
const err = new SfError('test', undefined, undefined, nestedError);
expect(inspect(err)).to.include('SfError: test');
expect(inspect(err)).to.include('sfErrorTest.ts');
expect(inspect(err)).to.include('sfError.test.ts');
expect(inspect(err)).to.include('nested');
expect(inspect(err)?.match(causeRegex)).to.have.lengthOf(1);
expect(inspect(err)?.match(nestedCauseRegex)).to.be.null;
Expand All @@ -97,7 +97,7 @@ describe('SfError', () => {
const nestedError2 = new Error('nested2', { cause: nestedError });
const err = new SfError('test', undefined, undefined, nestedError2);
expect(inspect(err)).to.include('SfError: test');
expect(inspect(err)).to.include('sfErrorTest.ts');
expect(inspect(err)).to.include('sfError.test.ts');
expect(inspect(err)).to.include('nested');
expect(inspect(err)).to.include('nested2');
expect(inspect(err)?.match(causeRegex)).to.have.lengthOf(1);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

2 comments on commit 4bf9406

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 4bf9406 Previous: 00155a3 Ratio
Child logger creation 465906 ops/sec (±1.38%) 455392 ops/sec (±0.97%) 0.98
Logging a string on root logger 781598 ops/sec (±8.00%) 791037 ops/sec (±9.82%) 1.01
Logging an object on root logger 569457 ops/sec (±10.56%) 591149 ops/sec (±6.70%) 1.04
Logging an object with a message on root logger 6602 ops/sec (±212.40%) 6496 ops/sec (±209.46%) 0.98
Logging an object with a redacted prop on root logger 487604 ops/sec (±6.71%) 467577 ops/sec (±9.12%) 0.96
Logging a nested 3-level object on root logger 368897 ops/sec (±6.98%) 340281 ops/sec (±8.75%) 0.92

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: 4bf9406 Previous: 00155a3 Ratio
Child logger creation 325705 ops/sec (±1.05%) 328177 ops/sec (±0.88%) 1.01
Logging a string on root logger 733623 ops/sec (±4.72%) 750018 ops/sec (±7.39%) 1.02
Logging an object on root logger 589539 ops/sec (±5.91%) 605448 ops/sec (±5.27%) 1.03
Logging an object with a message on root logger 6303 ops/sec (±204.07%) 8073 ops/sec (±200.70%) 1.28
Logging an object with a redacted prop on root logger 472344 ops/sec (±8.66%) 424643 ops/sec (±16.05%) 0.90
Logging a nested 3-level object on root logger 337048 ops/sec (±4.39%) 329864 ops/sec (±6.00%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.