Skip to content

WHAT IFFFFFFF THOUGH #30611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion packages/angular/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"@angular/platform-browser": "20.1.0-next.3",
"@angular/platform-server": "20.1.0-next.3",
"@angular/router": "20.1.0-next.3",
"@schematics/angular": "workspace:*"
"@schematics/angular": "workspace:*",
"vitest": "3.2.4"
},
"sideEffects": false,
"schematics": "./schematics/collection.json",
Expand Down
24 changes: 22 additions & 2 deletions packages/angular/ssr/test/utils/promise_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,36 @@
import { setTimeout } from 'node:timers/promises';
import { promiseWithAbort } from '../../src/utils/promise';

function expectRejectedWithError(promise: Promise<any>) {
if (typeof expectAsync === 'function') {
return expectAsync(promise).toBeRejectedWithError();
} else {
// @ts-expect-error
return expect(promise).rejects.toThrowError();
}
}

function expectResolved(promise: Promise<any>) {
if (typeof expectAsync === 'function') {
return expectAsync(promise).toBeResolved();
} else {
// @ts-expect-error
return expect(promise).resolves;
}
}

describe('promiseWithAbort', () => {
it('should reject with an AbortError when the signal is aborted', async () => {
const abortController = new AbortController();
const promise = promiseWithAbort(setTimeout(500), abortController.signal, 'Test operation');

console.error('queueMicrotask to abort the signal');
queueMicrotask(() => {
abortController.abort('Test reason');
});

await expectAsync(promise).toBeRejectedWithError();
console.error('expectAsync to be rejected with AbortError');
await expectRejectedWithError(promise);
});

it('should not reject if the signal is not aborted', async () => {
Expand All @@ -31,6 +51,6 @@ describe('promiseWithAbort', () => {
// Wait briefly to ensure no rejection occurs
await setTimeout(20);

await expectAsync(promise).toBeResolved();
await expectResolved(promise);
});
});
8 changes: 8 additions & 0 deletions packages/angular/ssr/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['**/*_spec.ts'],
globals: true,
},
});
1 change: 1 addition & 0 deletions packages/ngtools/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@angular/compiler": "20.1.0-next.3",
"@angular/compiler-cli": "20.1.0-next.3",
"typescript": "5.8.3",
"vitest": "3.2.4",
"webpack": "5.99.9"
}
}
8 changes: 8 additions & 0 deletions packages/ngtools/webpack/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['**/*_spec.ts'],
globals: true,
},
});
72 changes: 11 additions & 61 deletions pnpm-lock.yaml

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

20 changes: 20 additions & 0 deletions tools/vitest_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def _vitest_test_impl(ctx):
pass

_vitest_test = rule()

def vitest_test(data = [], args = [], **kwargs):
# Create relative path to root, from current package dir. Necessary as
# we change the `chdir` below to the package directory.
relative_to_root = "/".join([".."] * len(native.package_name().split("/")))

_vitest_test(
node_modules = "//:node_modules",
chdir = native.package_name(),
args = [
# Escape so that the `js_binary` launcher triggers Bash expansion.
"'**/*+(.|_)spec.js'",
] + args,
data = data + ["//:node_modules/vitest"],
**kwargs
)