Giter VIP home page Giter VIP logo

vue3-recaptcha-v2's People

Contributors

dongkyuuuu avatar imshara avatar s00d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue3-recaptcha-v2's Issues

Nuxt 3 usage

For people wanting to use this in Nuxt3 (rc3). It is possible with client side only plugin and component

in file plugins/recaptcha.client.ts

import install from "vue3-recaptcha-v2";
import { defineNuxtPlugin, useRuntimeConfig } from "#app";

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(install, {
    siteKey: useRuntimeConfig().public.recaptcha.siteKey
  });
});

and in yourcomponent.vue do

<template>
  <div>
    <client-only>
      <VueRecaptcha
        theme="light"
        size="normal"
        :tabindex="0"
        @widgetId="recaptchaWidget = $event"
        @verify="callbackVerify($event)"
        @expired="callbackExpired()"
        @fail="callbackFail()"
      />
    </client-only>
  </div>
</template>
....

The registering of the plugin will probably change in later versions of Nuxt3

unittesting vue3-recaptcha-v2, "Cannot set properties of null"

For the life of me, I can't figure out how to erect a unit test harness for a project that includes vue3-recaptcha-v2. I know it's something I'm missing, but was hoping someone could point me in the right direction.

Simple app, which works fine:

<script setup>
import { ref } from "vue"
import { VueRecaptcha } from "vue3-recaptcha-v2"
const recaptchaWidget = ref(null)
</script>

<template>
<vue-recaptcha @widget-id="recaptchaWidget = $event" />
</template>

Unit test:

import { describe, it } from 'vitest'
import { mount, config } from '@vue/test-utils'
import VueRecaptcha from 'vue3-recaptcha-v2'
import App from '../App.vue'

config.plugins.VueWrapper.install(VueRecaptcha, { siteKey: 'fake-key'})

describe('App test', () => {
  it('mount properly', () => {
    mount(App)
  })
})

A run of npm run test:unit

Yields the error:

stderr | src/__tests__/App.test.js > App test > mount properly
[Vue warn]: injection "Symbol(recaptchaSiteKey)" not found.
  at <VueRecaptcha onWidgetId=fn >
  at <App ref="VTU_COMPONENT" >
  at <VTUROOT>

 ❯ src/__tests__/App.test.js (1)
   ❯ App test (1)
     × mount properly

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/__tests__/App.test.js > App test > mount properly
TypeError: Cannot set properties of null (setting 'onload')
 ❯ node_modules/vue3-recaptcha-v2/dist/vue3-recaptcha-v2.js:1:1342

Versions

"dependencies": {
    "vue": "^3.2.47",
    "vue3-recaptcha-v2": "^1.0.1"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^4.0.0",
    "@vue/test-utils": "^2.3.0",
    "jsdom": "^21.1.0",
    "vite": "^4.1.4",
    "vitest": "^0.29.1"
  }

Any pointers would be greatly appreciated.

Language option problem

hello! thank you very much for the plugin.

I have a problem.

I can't change language in reCaptcha when language option is changed in my project.

There isn't language change option in plugin.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.