
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
@remotex-labs/xjet-expect
Advanced tools
xJet-Expect: Powerful Assertions for Seamless xJet Testing
A TypeScript-based matcher library for testing mocks and verifying function calls, thrown errors, and returned values.
Inspired by Jest-style assertions with xJet support for extended mock / spy in esm.
Install via npm:
npm install --save-dev @remotex-labs/xjet-expect
Or using yarn:
yarn add @remotex-labs/xjet-expect
import { expect, test } from '@remotex-labs/xjet-expect';
test('basic assertions', () => {
// Equality
expect(2 + 2).toBe(4);
expect({ name: 'test' }).toEqual({ name: 'test' });
// Truthiness
expect(true).toBeTruthy();
expect(null).toBeFalsy();
// Numbers
expect(10).toBeGreaterThan(5);
expect(5).toBeLessThanOrEqual(5);
// Strings
expect('hello world').toContain('world');
expect('test string').toMatch(/test/);
// Objects
expect({ user: { name: 'John' } }).toHaveProperty('user.name');
});
import { expect, test, jest } from '@remotex-labs/xjet-expect';
test('mock function calls', () => {
const mockFn = jest.fn();
mockFn('first call');
mockFn('second call');
// Verify calls
expect(mockFn).toHaveBeenCalled();
expect(mockFn).toHaveBeenCalledTimes(2);
expect(mockFn).toHaveBeenCalledWith('first call');
expect(mockFn).toHaveBeenLastCalledWith('second call');
expect(mockFn).toHaveBeenNthCalledWith(1, 'first call');
});
test('mock return values', () => {
const mockFn = jest.fn()
.mockReturnValueOnce('first')
.mockReturnValueOnce('second');
expect(mockFn()).toBe('first');
expect(mockFn()).toBe('second');
expect(mockFn).toHaveReturned();
expect(mockFn).toHaveReturnedTimes(2);
expect(mockFn).toHaveLastReturnedWith('second');
expect(mockFn).toHaveNthReturnedWith(1, 'first');
});
import { expect, test } from '@remotex-labs/xjet-expect';
test('async functions', async () => {
// Promise resolution
await expect(Promise.resolve('success')).resolves.toBe('success');
await expect(Promise.resolve({ id: 123 })).resolves.toHaveProperty('id');
// Promise rejection
await expect(Promise.reject(new Error('failed'))).rejects.toThrow('failed');
// Async functions
const fetchData = async () => ({ id: 123, name: 'test' });
await expect(fetchData()).resolves.toEqual(
expect.objectContaining({ id: expect.any(Number) })
);
});
import { expect, test } from '@remotex-labs/xjet-expect';
test('flexible assertions with asymmetric matchers', () => {
const user = {
id: 123,
name: 'John Doe',
email: 'john@example.com',
createdAt: new Date(),
roles: ['user', 'admin']
};
expect(user).toEqual(expect.objectContaining({
id: expect.any(Number),
name: expect.stringContaining('John'),
email: expect.stringMatching(/^.+@example\.com$/),
createdAt: expect.any(Date),
roles: expect.arrayContaining(['admin'])
}));
});
import { expect } from '@remotex-labs/xjet-expect';
// Define a custom matcher
expect.extend({
toBeEvenNumber(received) {
const pass = typeof received === 'number' && received % 2 === 0;
return {
pass,
message: () => `Expected ${received} ${pass ? 'not ' : ''}to be an even number`
};
}
});
// Use custom matcher
test('custom matchers', () => {
expect(4).toBeEvenNumber();
expect(3).not.toBeEvenNumber();
});
For complete API documentation, examples, and guides, visit: xJet-expect Documentation
Contributions are welcome! Please see our Contributing Guide for details.
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
FAQs
xJet-Expect: Powerful Assertions for Seamless xJet Testing
The npm package @remotex-labs/xjet-expect receives a total of 351 weekly downloads. As such, @remotex-labs/xjet-expect popularity was classified as not popular.
We found that @remotex-labs/xjet-expect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.