Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
de: '13',
en: '42',
}))
// Mock annoying components (e.g. too much vuex dependency)
jest.mock('@/authuser/components/Settings/VerificationWarning', () => ({
render: h => h('div', 'VerificationWarning has been mocked'),
}))
const files = glob.sync('**/*.story.js', { absolute: true })
for (const f of files) {
require(f)
}
// use server side renderer to get renderered html string
const renderer = createRenderer()
for (const group of mockStories) {
describe('Storyshots', () => {
describe(group.kind, () => {
for (const story of group.stories) {
it(story.name, async () => {
// get the component from storybook
const component = story.render()
const wrapper = mount(component, {
sync: false,
mocks: {
...routerMocks,
},
})
const html = await renderer.renderToString(wrapper.vm)
VueSSR.createApp = createApp
`
VueSSR.createApp = function () {
return new Vue({
template: VueSSR.defaultAppTemplate,
})
}
VueSSR.ssrContext = new Meteor.EnvironmentVariable()
VueSSR.inSubscription = new Meteor.EnvironmentVariable() // <-- needed in data.js
patchSubscribeData(VueSSR)
const renderer = createRenderer()
function writeServerError (sink) {
sink.appendToBody('Server Error')
}
WebApp.rawConnectHandlers.use(cookieParser())
onPageLoad(sink => new Promise((resolve, reject) => {
const req = sink.request
// Fast render
const loginToken = req.cookies['meteor_login_token']
const headers = req.headers
const frLoginContext = new FastRender._Context(loginToken, { headers })
FastRender.frContext.withValue(frLoginContext, function () {
it('matches snapshot', async () => {
const renderer = createRenderer()
const wrapper = mount(Test)
const str = await renderer.renderToString(wrapper.vm)
expect(str).toMatchSnapshot()
})
it('matches snapshot', async () => {
const renderer = createRenderer()
const wrapper = mount(Test)
const str = await renderer.renderToString(wrapper.vm)
expect(str).toMatchSnapshot()
})
each(materialComponents, (component, key) => {
const renderer = createRenderer();
const spyDestroy = sinon.stub();
const spyLoadData = sinon.stub();
localVue.use(component, options);
const cmpName = key.split(/(?=[A-Z])/).join('-').toLowerCase();
const cmp = localVue.options.components[cmpName];
const cmpDefinition = mockDefinition[cmpName];
if (!cmpDefinition) return;
const { type } = cmpDefinition._schema;
const { group } = cmpDefinition._schema;
const definition = assign({ type }, cmpDefinition);
const wrapper = mount(cmp, {
localVue,
export default function renderToString (
component: Component,
options: Options = {}
): string {
const renderer = createRenderer()
if (!renderer) {
throwError(
`renderToString must be run in node. It cannot be ` + `run in a browser`
)
}
if (options.attachToDocument) {
throwError(`you cannot use attachToDocument with ` + `renderToString`)
}
const vm = createInstance(
component,
mergeOptions(options, config),
testUtils.createLocalVue(options.localVue)
)
constructor(compiler: ICompiler, options?: RendererOptionParams) {
super();
this.compiler = compiler;
this.vueRenderer = vueServerRenderer.createRenderer();
this.options = Object.assign({}, defaultRendererOptions, options);
this.init();
}
it('snapshot: has same HTML structure', () => {
const renderer = createRenderer()
renderer.renderToString(wrapper.vm, (err, str) => {
if (err) {
throw new Error(err)
}
expect(str).toMatchSnapshot()
})
})
})
var _defaults = require('../defaults');
var _string = require('./string');
var _meta = require('./meta');
var _meta2 = _interopRequireDefault(_meta);
var _paramCase = require('param-case');
var _paramCase2 = _interopRequireDefault(_paramCase);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var renderer = require('vue-server-renderer').createRenderer();
var appRegex = /{{{app}}}/igm;
var scriptRegex = /{{{script}}}/igm;
var headRegex = /<\/head>/igm;
var types = new _defaults.Types();
function createApp(script) {
var Vue = require('vue');
return new Vue(script);
}
function layoutUtil(components) {
var layout = {};
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
createRenderer () {
return createRenderer()
}