
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@bagaar/ember-graphql-mocking
Advanced tools
Ember addon for mocking GraphQL requests using Mock Service Worker (MSW).
Ember addon for mocking GraphQL requests using Mock Service Worker (MSW).
npm install -D @bagaar/ember-graphql-mocking msw
pnpm add -D @bagaar/ember-graphql-mocking msw
yarn add -D @bagaar/ember-graphql-mocking msw
In tests/test-helper.js
:
setupEmberGraphqlMocking
setupEmberGraphqlMocking
with your GraphQL schema// tests/test-helper.js
import Application from 'my-app/app';
import config from 'my-app/config/environment';
import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start } from 'ember-qunit';
import { setupEmberGraphqlMocking } from '@bagaar/ember-graphql-mocking/test-support'; // 1.
import schema from 'my-app/graphql/schema'; // 2.
QUnit.begin(() => setupEmberGraphqlMocking(schema)); // 3.
setApplication(Application.create(config.APP));
setup(QUnit.assert);
start();
[!NOTE] Make sure to use
QUnit.begin
, assetupEmberGraphqlMocking
returns a Promise.
If you want to pass along additional start options
to MSW's service worker, you can do so by defining an mswStartOptions
object:
QUnit.begin(() =>
setupEmberGraphqlMocking(schema, {
mswStartOptions: {
// Additional MSW start options...
},
})
);
mockResolvers
and setupGraphqlTest
setupGraphqlTest
with hooks
mockResolvers
to mock the necessary resolver(s) per testsetupGraphqlTest
will make sure that all resolvers are cleared in between tests.
mockResolvers
accepts an object that consists of one or more resolvers. The key must be the name of the mocked operation, the value can either be a response object or a function that returns a response object.
[!NOTE] Make sure that your operations are named in order for
@bagaar/ember-graphql-mocking
to function properly.
// tests/acceptance/my-acceptance-test.js
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'my-app/tests/helpers';
import { mockResolvers, setupGraphqlTest } from '@bagaar/ember-graphql-mocking/test-support'; // 1.
module('Acceptance | ember-graphql-mocking', function (hooks) {
setupApplicationTest(hooks);
setupGraphqlTest(hooks); // 2.
test('visiting /', async function (assert) {
mockResolvers({ // 3.
me: {
id: '1',
firstName: 'John',
lastName: 'Doe',
},
});
await visit('/');
assert.strictEqual(currentURL(), '/');
assert.dom('[data-test-me-id]').hasText('1');
assert.dom('[data-test-me-first-name]').hasText('John');
assert.dom('[data-test-me-last-name]').hasText('Doe');
});
});
[!NOTE] Calling
mockResolvers
multiple times within a single test, will simply merge all resolvers into a single root.
[!NOTE] Working versions of these code examples can be found in this addon's test app.
See the Contributing guide for details.
This project is licensed under the MIT License.
FAQs
Ember addon for mocking GraphQL requests using Mock Service Worker (MSW).
The npm package @bagaar/ember-graphql-mocking receives a total of 36 weekly downloads. As such, @bagaar/ember-graphql-mocking popularity was classified as not popular.
We found that @bagaar/ember-graphql-mocking demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
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.