@@ -243,7 +243,7 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
243243
244244 it('should handle spy call order', () => {
245245 const spyA = jasmine.createSpy('spyA');
246- const spyB = jasmine.createSpy('spyB' );
246+ const spyB = jasmine.createSpy();
247247 spyA();
248248 spyB();
249249 expect(spyA).toHaveBeenCalledBefore(spyB);
@@ -288,7 +288,7 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
288288 });
289289
290290 it('should handle spy call order', () => {
291- const spyA = vi.fn();
291+ const spyA = vi.fn().mockName('spyA') ;
292292 const spyB = vi.fn();
293293 spyA();
294294 spyB();
@@ -340,12 +340,28 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
340340 }
341341 });
342342
343+ it('should handle fail() with a specific error', () => {
344+ try {
345+ expect(1).toBe(2);
346+ fail(new Error('Expected test to fail'));
347+ } catch (err) {
348+ expect(err.message).toBe('1 !== 2');
349+ }
350+ });
351+
343352 it('should handle spyOnProperty', () => {
344353 const obj = { get myProp() { return 'original'; } };
345354 spyOnProperty(obj, 'myProp', 'get').and.returnValue('mocked');
346355 expect(obj.myProp).toBe('mocked');
347356 });
348357
358+ it('should handle async spies', async () => {
359+ const ctx = { myMethod: () => Promise.resolve('real') };
360+ spyOn(ctx, 'myMethod').and.returnValue(Promise.resolve('mocked'));
361+
362+ expect(await ctx.myMethod()).toBe('mocked');
363+ });
364+
349365 it('should handle spies throwing errors', () => {
350366 const spy = jasmine.createSpy('mySpy').and.throwError('Test Error');
351367 expect(() => spy()).toThrowError('Test Error');
@@ -380,14 +396,30 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
380396 }
381397 });
382398
399+ it('should handle fail() with a specific error', () => {
400+ try {
401+ expect(1).toBe(2);
402+ throw new Error('Expected test to fail');
403+ } catch (err) {
404+ expect(err.message).toBe('1 !== 2');
405+ }
406+ });
407+
383408 it('should handle spyOnProperty', () => {
384409 const obj = { get myProp() { return 'original'; } };
385410 vi.spyOn(obj, 'myProp', 'get').mockReturnValue('mocked');
386411 expect(obj.myProp).toBe('mocked');
387412 });
388413
414+ it('should handle async spies', async () => {
415+ const ctx = { myMethod: () => Promise.resolve('real') };
416+ vi.spyOn(ctx, 'myMethod').mockResolvedValue('mocked');
417+
418+ expect(await ctx.myMethod()).toBe('mocked');
419+ });
420+
389421 it('should handle spies throwing errors', () => {
390- const spy = vi.fn().mockImplementation(() => { throw new Error('Test Error') });
422+ const spy = vi.fn().mockName('mySpy'). mockImplementation(() => { throw new Error('Test Error') });
391423 expect(() => spy()).toThrowError('Test Error');
392424 });
393425 });
@@ -438,6 +470,8 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
438470 const jasmineCode = `
439471 describe('Unsupported Features', () => {
440472 beforeAll(() => {
473+ jasmine.MAX_PRETTY_PRINT_CHARS = 100;
474+
441475 jasmine.addMatchers({
442476 toBeAwesome: () => ({
443477 compare: (actual) => ({ pass: actual === 'awesome' })
@@ -467,6 +501,8 @@ describe('Jasmine to Vitest Transformer - Integration Tests', () => {
467501 const vitestCode = `
468502 describe('Unsupported Features', () => {
469503 beforeAll(() => {
504+ // TODO: vitest-migration: jasmine.MAX_PRETTY_PRINT_CHARS is not supported.
505+ // jasmine.MAX_PRETTY_PRINT_CHARS = 100;
470506 // TODO: vitest-migration: jasmine.addMatchers is not supported. Please manually migrate to expect.extend(). See: https://vitest.dev/api/expect.html#expect-extend
471507 jasmine.addMatchers({
472508 toBeAwesome: () => ({
0 commit comments