Skip to main content

Class: SqlAssertions

Defined in: src/testing/SqlAssertions.ts:12

Custom assertions for testing SQL generation and parameter bindings.

Accessors​

sql​

Get Signature​

get sql(): string

Defined in: src/testing/SqlAssertions.ts:40

Returns​

string


params​

Get Signature​

get params(): any[]

Defined in: src/testing/SqlAssertions.ts:44

Returns​

any[]

Constructors​

Constructor​

new SqlAssertions(target): SqlAssertions

Defined in: src/testing/SqlAssertions.ts:16

Parameters​

ParameterType
targetstring | QueryBuilder<any> | DbSet<any> | SqlQueryResult | { toSelectSql: () => SqlQueryResult; }

Returns​

SqlAssertions

Methods​

toSQL()​

toSQL(expectedSql): this

Defined in: src/testing/SqlAssertions.ts:51

Asserts that the generated SQL exactly equals the expected SQL string (normalizing whitespace).

Parameters​

ParameterType
expectedSqlstring

Returns​

this


toContainSql()​

toContainSql(fragment): this

Defined in: src/testing/SqlAssertions.ts:65

Asserts that the generated SQL contains the given fragment.

Parameters​

ParameterType
fragmentstring

Returns​

this


toMatchParams()​

toMatchParams(expectedParams): this

Defined in: src/testing/SqlAssertions.ts:79

Asserts that the generated query params match the expected parameter array or values.

Parameters​

ParameterType
expectedParamsany[]

Returns​

this