Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"no-trailing-spaces": [ "warn", { "skipBlankLines": true }],// Enabled for auto fixing
"no-const-assign": "error",
"comma-dangle": [ "error", "never" ], // Enabled for auto fixing
"semi": [ "error", "always" ], // Enabled for auto fixing
"security/detect-object-injection": "off", // Suppress Warning -- need to Review Later
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-unused-vars": [ "warn", { "vars": "all", "args": "none", "argsIgnorePattern": "^_", "ignoreRestSiblings": true } ],
Expand Down
85 changes: 84 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,91 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 5
groups:
nevware21:
patterns:
- "@nevware21/*"
types:
patterns:
- "@types/*"
grunt:
patterns:
- "grunt*"
puppeteer:
patterns:
- "puppeteer"
rollup:
patterns:
- "rollup*"
- "@rollup/*"
typescript:
patterns:
- "typescript*"
- "typedoc"
- "karma-typescript"
- "nyc"
- "@istanbuljs/nyc-config-typescript"
- "*mocha*"

- package-ecosystem: "npm" # See documentation for possible values
directory: "/lib" # Location of package manifests
directory: "/core" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 5
groups:
nevware21:
patterns:
- "@nevware21/*"
types:
patterns:
- "@types/*"
grunt:
patterns:
- "grunt*"
puppeteer:
patterns:
- "puppeteer"
rollup:
patterns:
- "rollup*"
- "@rollup/*"
typescript:
patterns:
- "typescript*"
- "typedoc"
- "karma-typescript"
- "nyc"
- "@istanbuljs/nyc-config-typescript"
- "*mocha*"

- package-ecosystem: "npm" # See documentation for possible values
directory: "/shim" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 5
groups:
nevware21:
patterns:
- "@nevware21/*"
types:
patterns:
- "@types/*"
grunt:
patterns:
- "grunt*"
puppeteer:
patterns:
- "puppeteer"
rollup:
patterns:
- "rollup*"
- "@rollup/*"
typescript:
patterns:
- "typescript*"
- "typedoc"
- "karma-typescript"
- "nyc"
- "@istanbuljs/nyc-config-typescript"
- "*mocha*"
33 changes: 4 additions & 29 deletions common/config/rush/npm-shrinkwrap.json

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

3 changes: 2 additions & 1 deletion core/karma.browser.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = function (config) {
{ pattern: "test/src/**/*.ts" }
],
preprocessors: {
"**/*.ts": [ "karma-typescript" ]
"src/**/*.ts": [ "karma-typescript" ],
"test/src/**/*.ts": [ "karma-typescript" ]
},
karmaTypescriptConfig: {
tsconfig: "./test/tsconfig.browser.karma.json",
Expand Down
7 changes: 4 additions & 3 deletions core/karma.debug.worker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function (config) {
const typescript = require("@rollup/plugin-typescript");
const plugin = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");

config.set({
browsers: ["Chromium_without_security"],
listenAddress: 'localhost',
Expand All @@ -21,9 +22,9 @@ module.exports = function (config) {
typescript({
tsconfig: "./test/tsconfig.worker.karma.json"
}),
// plugin.nodeResolve({
// browser: true
// }),
plugin.nodeResolve({
browser: true
})
// commonjs()
],
output: {
Expand Down
9 changes: 7 additions & 2 deletions core/karma.worker.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ module.exports = function (config) {
}),
//commonjs(),
istanbul({
exclude: [ "**/test/**", "**/node_modules/**" ]
exclude: [
"**/index.ts",
"**/test/**",
"**/checkError.ts",
"**/node_modules/**"
]
})
],
output: {
format: "iife",
dir: "../test-dist",
dir: "./test-dist",
sourcemap: true
}
},
Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"dependencies": {
"@nevware21/ts-utils": ">= 0.12.3 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x",
"@nevware21/chromacon": ">= 0.1.2 < 2.x",
"@nevware21/chromacon": ">= 0.1.3 < 2.x",
"tslib": "^2.3.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions core/src/assert/adapters/evalAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export function createEvalAdapter(evalFn: EvalFn, evalMsg?: MsgSource, funcName?
}

theArgs.unshift(context.value);
context.eval(evalFn.apply(scope.that || scope, theArgs), evalMsg)
context.eval(evalFn.apply(scope.that || scope, theArgs), evalMsg);

return scope.that
return scope.that;
}

return _blockLength(_evalFn, funcName, [], _evalFn);
Expand Down
4 changes: 2 additions & 2 deletions core/src/assert/adapters/exprAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function _runExpr(theAssert: any, scope: IAssertScope, steps: IStepDef[], scopeF

if (!(step.name in scope.that)) {
throw new AssertionError(
`${idx} Invalid step: ${step.name} for [${steps.map(s => s.name).join("->")}] available steps: [${objKeys(scope.that).join(";")}] - ${_formatValue(scope.that)}`,
`${idx} Invalid step: ${step.name} for [${steps.map(s => s.name).join("->")}] available steps: [${objKeys(scope.that).join(";")}] - ${_formatValue(scope.context, scope.that)}`,
null,
context._$stackFn);
}
Expand Down Expand Up @@ -176,7 +176,7 @@ function _processFn(scope: IAssertScope, scopeFn: IScopeFn, theArgs: any[], theR
if (scopeFn) {
// Track the operation path and set the stack start position
if (scope.context.opts.isVerbose) {
let theScopeName = scopeFn.name || (scopeFn as any)["displayName"] || "anonymous"
let theScopeName = scopeFn.name || (scopeFn as any)["displayName"] || "anonymous";
scope.context.setOp("[[" + theScopeName + "]]");
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/assert/assertClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { hasPropertyFunc } from "./funcs/hasProperty";
import { AssertionError, AssertionFailure } from "./assertionError";
import { createContext } from "./scopeContext";
import { createAssertScope } from "./assertScope";
import { assertConfig } from "./config";
import { IScopeFn } from "./interface/IScopeFuncs";
import { createExprAdapter } from "./adapters/exprAdapter";
import { isSealedFunc } from "./funcs/isSealed";
Expand Down Expand Up @@ -344,7 +345,7 @@ function _createAliasFunc(alias: string) {

function _createProxyFunc(theAssert: IAssertClass, assertName: string, def: IAssertClassDef, internalErrorStackStart: Function, responseHandler: (result: any) => any): IScopeFn {
// let steps: IStepDef[];
let scopeFn: IScopeFn = def.scopeFn
let scopeFn: IScopeFn = def.scopeFn;
let mIdx: number = def.mIdx || -1;
let numArgs: number = isNullOrUndefined(def.nArgs) ? 1 : def.nArgs;

Expand All @@ -370,7 +371,7 @@ function _createProxyFunc(theAssert: IAssertClass, assertName: string, def: IAss

// Create the initial scope `expect(value, initMsg)` and run any defined steps
// Using either the current alias entry point or the current function
let newScope = createAssertScope(createContext(actualValue, initMsg, _aliasStackStart || _assertFunc, orgArgs));
let newScope = createAssertScope(createContext(actualValue, initMsg, _aliasStackStart || _assertFunc, orgArgs, assertConfig));
newScope.context._$stackFn.push(_aliasStackStart || _assertFunc);

newScope.context.setOp(assertName + "()");
Expand Down
7 changes: 5 additions & 2 deletions core/src/assert/assertScope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AssertInstHandlers } from "./interface/IAssertInstHandlers";
import { _createLazyInstHandler, _setAssertScope } from "./internal/_instCreator";
import { _tripwireAssertHandlers } from "./internal/_tripwireInst";
import { _failFn, _fatalFn } from "./internal/_failFn";
import { useScope } from "./useScope";


/**
Expand Down Expand Up @@ -103,7 +104,7 @@ export function createAssertScope(context: IScopeContext, handlerCreator?: Asser
*/
function updateCtx<T>(value: T, overrides?: IScopeContextOverrides): IAssertScope {
if (value !== _context.value || overrides) {
_context = _context.new(value, overrides)
_context = _context.new(value, overrides);
}

return theScope;
Expand All @@ -125,7 +126,9 @@ export function createAssertScope(context: IScopeContext, handlerCreator?: Asser
_context.set(EXEC, theFuncName);
_context._$stackFn.push(_exec);

return fn.apply(theScope, args);
return useScope(_context, () => {
return fn.apply(theScope, args);
});
}

function fail(failMsg: MsgSource, details?: any): never;
Expand Down
22 changes: 14 additions & 8 deletions core/src/assert/assertionError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
* Licensed under the MIT license.
*/

import { arrMap, arrSlice, asString, createCustomError, CustomErrorConstructor, getLazy, isArray, isError, newSymbol, objDefine, objDefineProps, objForEachKey, objKeys, strTrim } from "@nevware21/ts-utils"
import { arrMap, arrSlice, asString, createCustomError, CustomErrorConstructor, getLazy, isArray, isError, newSymbol, objDefine, objDefineProps, objForEachKey, objKeys, strTrim } from "@nevware21/ts-utils";
import { EMPTY_STRING } from "./internal/const";
import { _formatValue } from "./internal/_formatValue";
import { IParsedStack, parseStack } from "../internal/parseStack";
import { captureStack } from "../internal/captureStack";
import { IScopeContext } from "./interface/IScopeContext";
import { _getGlobalScopeContext } from "./useScope";

const cStackDetail = newSymbol("@nevware21/tripwire#_$stackDetail");

Expand Down Expand Up @@ -120,11 +122,13 @@ export interface AssertionErrorConstructor<T> extends CustomErrorConstructor<Ass
* Formats the properties of the error for display.
*
* @param props - The properties to format.
* @param ctx - The format context to use for formatting values, or null if not available.
* @returns A formatted string representation of the properties.
*/
function _formatProps(props: any): string {
if (props) {
function _formatProps(ctx: IScopeContext | null, props: any): string {
if (props && ctx) {
let formatted = " ::: ";

if (props.operation || isArray(props.opPath)) {
let thePath = EMPTY_STRING;
let lastOp = props.operation || EMPTY_STRING;
Expand All @@ -136,15 +140,15 @@ function _formatProps(props: any): string {
thePath = props.opPath.join("->") + "->" + lastOp;
}
} else {
thePath = _formatValue(props.opPath) + "->" + lastOp;
thePath = _formatValue(ctx, props.opPath) + "->" + lastOp;
}
} else {
thePath = _formatValue(props.opPath);
thePath = _formatValue(ctx, props.opPath);
}

formatted += "running \"" + thePath + "\"";
if (props.actual) {
formatted += " with (" + _formatValue(props.actual) + ")";
formatted += " with (" + _formatValue(ctx, props.actual) + ")";
}
let leftOver: any = {};
objForEachKey(props, (key, value) => {
Expand All @@ -167,7 +171,7 @@ function _formatProps(props: any): string {
}
}

return formatted
return formatted;
}

return EMPTY_STRING;
Expand Down Expand Up @@ -240,7 +244,9 @@ function _setMessage(theError: Error, message: string) {
let theMessage = message || EMPTY_STRING;

if ((theError as any).props) {
theMessage += _formatProps((theError as any).props)
let props = (theError as any).props;
// Get format context from global scope context if available
theMessage += _formatProps(_getGlobalScopeContext(), props);
}

// If we have an inner exception, then we need to add the inner exception stack
Expand Down
Loading