How to use the vue-server-renderer.createRenderer function in vue-server-renderer

To help you get started, we’ve selected a few vue-server-renderer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yunity / karrot-frontend / src / storyshots.spec.js View on Github external
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)
github meteor-vue / vue-meteor / packages / vue-ssr / server / index.js View on Github external
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 () {
github vuikit / vuikit / packages / vuikit / src / library / button / __tests__ / button.js View on Github external
it('matches snapshot', async () => {
    const renderer = createRenderer()
    const wrapper = mount(Test)

    const str = await renderer.renderToString(wrapper.vm)
    expect(str).toMatchSnapshot()
  })
github vuikit / vuikit / packages / vuikit / src / library / label / __tests__ / label.js View on Github external
it('matches snapshot', async () => {
    const renderer = createRenderer()
    const wrapper = mount(Test)

    const str = await renderer.renderToString(wrapper.vm)
    expect(str).toMatchSnapshot()
  })
github nsftx / chameleon-bundle-material / tests / unit / spec / elements.spec.js View on Github external
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,
github vuejs / vue-test-utils / packages / server-test-utils / src / renderToString.js View on Github external
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)
  )
github leaves4j / vue-easy-renderer / src / renderer / renderer.js View on Github external
constructor(compiler: ICompiler, options?: RendererOptionParams) {
    super();
    this.compiler = compiler;
    this.vueRenderer = vueServerRenderer.createRenderer();
    this.options = Object.assign({}, defaultRendererOptions, options);
    this.init();
  }
github Royal-Navy / standards-toolkit / deprecated / vue-component-library / src / components / RnTable / RnTable.spec.js View on Github external
it('snapshot: has same HTML structure', () => {
    const renderer = createRenderer()
    renderer.renderToString(wrapper.vm, (err, str) => {
      if (err) {
        throw new Error(err)
      }

      expect(str).toMatchSnapshot()
    })
  })
})
github express-vue / express-vue / dist / utils / render.js View on Github external
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;