
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@remotex-labs/xjet-expect
Advanced tools
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 { xExpect, test } from '@remotex-labs/xjet-expect';
test('basic assertions', () => {
// Equality
xExpect(2 + 2).toBe(4);
xExpect({ name: 'test' }).toEqual({ name: 'test' });
// Truthiness
xExpect(true).toBeTruthy();
xExpect(null).toBeFalsy();
// Numbers
xExpect(10).toBeGreaterThan(5);
xExpect(5).toBeLessThanOrEqual(5);
// Strings
xExpect('hello world').toContain('world');
xExpect('test string').toMatch(/test/);
// Objects
xExpect({ user: { name: 'John' } }).toHaveProperty('user.name');
});
import { xExpect, test, jest } from '@remotex-labs/xjet-expect';
test('mock function calls', () => {
const mockFn = jest.fn();
mockFn('first call');
mockFn('second call');
// Verify calls
xExpect(mockFn).toHaveBeenCalled();
xExpect(mockFn).toHaveBeenCalledTimes(2);
xExpect(mockFn).toHaveBeenCalledWith('first call');
xExpect(mockFn).toHaveBeenLastCalledWith('second call');
xExpect(mockFn).toHaveBeenNthCalledWith(1, 'first call');
});
test('mock return values', () => {
const mockFn = jest.fn()
.mockReturnValueOnce('first')
.mockReturnValueOnce('second');
xExpect(mockFn()).toBe('first');
xExpect(mockFn()).toBe('second');
xExpect(mockFn).toHaveReturned();
xExpect(mockFn).toHaveReturnedTimes(2);
xExpect(mockFn).toHaveLastReturnedWith('second');
xExpect(mockFn).toHaveNthReturnedWith(1, 'first');
});
import { xExpect, test } from '@remotex-labs/xjet-expect';
test('async functions', async () => {
// Promise resolution
await xExpect(Promise.resolve('success')).resolves.toBe('success');
await xExpect(Promise.resolve({ id: 123 })).resolves.toHaveProperty('id');
// Promise rejection
await xExpect(Promise.reject(new Error('failed'))).rejects.toThrow('failed');
// Async functions
const fetchData = async () => ({ id: 123, name: 'test' });
await xExpect(fetchData()).resolves.toEqual(
xExpect.objectContaining({ id: xExpect.any(Number) })
);
});
import { xExpect, 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']
};
xExpect(user).toEqual(xExpect.objectContaining({
id: xExpect.any(Number),
name: xExpect.stringContaining('John'),
email: xExpect.stringMatching(/^.+@example\.com$/),
createdAt: xExpect.any(Date),
roles: xExpect.arrayContaining(['admin'])
}));
});
import { xExpect } from '@remotex-labs/xjet-expect';
// Define a custom matcher
xExpect.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', () => {
xExpect(4).toBeEvenNumber();
xExpect(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
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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.